daijifeng001 / MNC

Instance-aware Semantic Segmentation via Multi-task Network Cascades
Other
489 stars 182 forks source link

The gradient derivation in ROIWarping Layer #52

Open yexiguafuqihao opened 7 years ago

yexiguafuqihao commented 7 years ago

@Oh233 ,I can't well understand the code: if (coordinate_index == 1) { // \par f / \par x1 weight = 0.5 dxc - dw; } else if (coordinate_index == 2) { // \par f / \par y1 weight = 0.5 dyc - dh; } else if (coordinate_index == 3) { // \par f / \par w weight = 0.5 dxc + dw; } else if (coordinate_index == 4) { // \par f / \par h weight = 0.5 dyc + dh; } in the function of get_coordinate_gradient in ROIWarpingLayer.cu in https://github.com/daijifeng001/caffe-mnc/blob/mnc/src/caffe/layers/roi_warping_layer.cu ,would you or anyone kindly please to afford me a detail explaination?I kown this is a partial derivative but I really can't figure out where 0.5 comes from?

handong1587 commented 7 years ago

Hi, I also get stuck in some code details like calculations of dw and dh Can someone help me to figure out how does 0.5 come about in formula (0.5 - map_ratio_w) ? I am a bit confused.

SunSet0864 commented 7 years ago

I think the dxc and dw/ dyc and dh should combine together and 0.5 will be disappeared using the function you have mentioned above, the last functions will be like that: 1-map_ratio_h or map_ratio_h-1 or -1-map_ratio_h or 1+map_ratio_h, the same for map_ratio_w; However, i have another question about the derivation, the equation (8) in the paper,wi is not a function of xi, so if we derivative for the xi, the wi will be zero,but from the code, we can see that the (u/W)*wi becomes u'/W` when we derivative the variable xi, so how to explain the (u'/W')?