criterion = nn.CrossEntropyLoss()
optimizer = torch.optim.Adam(rnn.parameters(), lr=learning_rate)
for i, (images, labels) in enumerate(train_loader):
    images = Variable(images.view(-1, sequence_length, input_size)).cuda()
       
    # Forward + Backward + Optimize
    optimizer.zero_grad()
    outputs = rnn(images)
    _, predicted = torch.max(outputs.data, 1)
    loss = criterion(outputs, predicted)
    loss.backward()
    optimizer.step()

error happen with line loss = criterion(outputs, predicted)
AttributeError: ‘torch.cuda.LongTensor’ object has no attribute 'requires_grad’
how can I use criterion with predicted? thank you