Hi
I have a same issue and I haven’t put any “requies_grad=false”. would you please advise about my codes.
# Model.
model = my_model()


criterium = nn.MSELoss()

# Adam optimizer with learning rate 0.1 and L2 regularization with weight 1e-4.
optimizer = torch.optim.Adam(model.parameters(),lr=0.1, weight_decay=1e-4)
# Set gradient to 0.
optimizer.zero_grad()

# Feed forward.
pred = model(data)
 _, output = torch.max(pred, 1)
output = output.type(torch.FloatTensor)

# Loss calculation.
loss = criterium(output, target)


# Gradient calculation.
loss.backward()

# Print loss every 10 iterations.
if k % 10 == 0:
    print('Loss {:.4f} at iter {:d}'.format(loss.item(), k))

# Model weight modification based on the optimizer.
optimizer.step()