Closed Sein-Kim closed 2 months ago
We added torch.no_grad()
to fix the error.
t_test = evaluate(model, dataset, args)
t_valid = evaluate_valid(model, dataset, args)
Modified Version - main.py:
with torch.no_grad():
t_test = evaluate(model, dataset, args)
t_valid = evaluate_valid(model, dataset, args)
Fixed
Error Message (at Commit Version: Hash)
RuntimeError: Output 0 of torch::autograd::CppNode is a view and is being modified inplace. This view was created inside a custom Function (or because an input was returned as-is) and the autograd logic to handle view+inplace would override the custom backward associated with the custom Function, leading to incorrect gradients. This behavior is forbidden. You can fix this by cloning the output of the custom Function.
The error message occurs when performing evaluations (validations or tests) after training the models.