Hi,
I’m trying to measure the gradient of a loss w.r.t. a specific set of feature maps of a CNN. This feature map would be an array. Is there a way to return this gradient through a function like backward()?
I was thinking of creating an attribute in the cnn model, containing the values of the feature maps, and then using the backward operation on the loss :
output = modelCNN.forward(input)
loss = loss_custom(output, target)
feature_map = modelCNN.feature_map
gradient_loss_wrt_featuremap = loss.backward(feature_map)
Could this work? The problem is that in the documentation of PyTorch, .backward() doesn’t have any return argument.
Any help is appreciated, thanks!
JP