How to get gradients of the output w.r.t. to a convolutional layer?

34 views
Skip to first unread message

Sandareka Wickramanayake

unread,
Aug 4, 2017, 12:40:41 PM8/4/17
to Caffe Users
Hi all, 

I'm trying to implement this paper - https://arxiv.org/abs/1610.02391 using python. For that I want to get gradient of the output of a specific class with respect to the last convolutional layer. I came across the following usage of backward() function. 

label = np.zeros((1, 6))
label[0, interested_class] = 1
net.backward(**{net.output[0]: label}) 

Assuming I have size classes in my network. 

However it gives gradient w.r.t to the input layer.

I tried to use the following usage but it is not giving the desirable output.

label = np.zeros((1,6))
label[0,interested_class] = 1
net.backward(end=conv, **{net.output[0]:label}) 

Precisely, I want to get the gradient of output layer w.r.t conv layer values. 

Any help is highly appreciated!

zhuwei

unread,
Jun 21, 2018, 7:04:17 PM6/21/18
to Caffe Users
Hi Sandareka,

I am working on the gradient visualization recently. Did you solve this problem?  

Any suggestions or advice will be greatly appreciated!



在 2017年8月4日星期五 UTC-4下午12:40:41,Sandareka Wickramanayake写道:

Sandareka Wickramanayake

unread,
Jun 21, 2018, 11:00:12 PM6/21/18
to Caffe Users
Hi Zhuwei, 

Please check if this post helps you. 
Reply all
Reply to author
Forward
0 new messages