-
Notifications
You must be signed in to change notification settings - Fork 18.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
What is the reason for having separate LayerSetUp
and Reshape
?
#1385
Comments
Have you seen https://github.com/BVLC/caffe/wiki/Development? |
@bhack That wiki page only reiterates what have already been stated in the code comments. It does not answer why such distinction is ever needed. The seemingly contradictory implementation in |
The wiki page tell you that setup is optional and is called only one-time. Reshape is not one time. |
@bhack Is it guaranteed that the same vector of blobs |
Reshape is called when network need a reshape |
|
@longjon It is nice to hear explanation from the one who originally proposes the change. But I still have some questions. In softmax_bottom_vec_.push_back(bottom[0]); But what if the next call, or next next next call of if instead it is actually a precondition for calling I asked this because I am writing a layer similar to |
Yes, the layers do in general assume that the bottom and top blobs will not change between calls, and the net implementation guarantees this. We should probably either document this fact or tweak the layer interface to make it more obvious; we could have the layers store the top and bottom passed into setup, making this assumption impossible to violate. |
@longjon Thanks. That clarifies my last bit of confusion. |
The latest dev branch of
caffe
splits the initialization code of each layer into two functions calledLayerSetUp
andReshape
. However, from the documentation I fail to infer the reason for this split and the distinction between the two. They are always called consecutively, so what purpose does it serve to separate two? And when I am writing a new layer, exactly what should be put inLayerSetUp
and what goes intoReshape
?I tried to read the source code for guidance, but here is the documentation for
LayerSetUp
:And here is the implementation of
caffe::SoftmaxWithLossLayer< Dtype >::LayerSetUp
:Contrary to the documentation,
caffe::SoftmaxWithLossLayer< Dtype >::LayerSetUp
does set up the internal "buffers" (here another layer embedded within), and it callsSetUp
function, which in turn callsReshape
so the top blobs do have their shape changed in this function.I am completely baffled.
The text was updated successfully, but these errors were encountered: