Open ruoyu0088 opened 5 years ago
here is the code that calculate the gradient in the book:
african_e66lephant_output = model.output[:, 386] grads = K.gradients(african_elephant_output, last_conv_layer.output)[0]
But in the reference article https://arxiv.org/abs/1610.02391
we first compute the gradient of the score for class c , y c (before the softmax), with respect to feature maps A k of a convolutional layer
It's said that we need the value before softmax, so I think maybe the following code is correct:
african_e66lephant_output = model.output.op.inputs[0][0, 386]
here is the code that calculate the gradient in the book:
But in the reference article https://arxiv.org/abs/1610.02391
It's said that we need the value before softmax, so I think maybe the following code is correct: