# wrap them in Variable
inputs = Variable(inputs.cuda())
labels = Variable(labels.cuda())
# zero the parameter gradients
optimizer.zero_grad()
# forward
outputs = model(inputs)
_, preds = torch.max(outputs, 1)
preds = preds.float()
loss = criterion(preds, labels)
loss.backward()
I’m trying to solve a classifying problem using code above. But I got the error “RuntimeError: there are no graph nodes that require computing gradients”. How should I solve it? Does it due to the function"torch.max"?Thanks in advance.