pytorch-grad-cam
pytorch-grad-cam copied to clipboard
set required_grad=True when init basecam class
I encountered the error AxisError: axis 2 is out of bounds for array of dimension 0
, which was caused by the value of grads
(the input of the function get_cam_weights
in every CAM class) being None. This occurred because no gradient was able to compute, due to the fact that model.required_grad was set to false during the training process by the user.
Hi and sorry for the late reply.
Maybe it makes sense to return the requires_grad to the initial state it was, when finishing?
Because this would alter the state of the model, and could affect training.