Skip to content
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

Added param skip_propagate_down to LayerParameter #2095

Merged
merged 1 commit into from
May 15, 2015

Conversation

mtamburrano
Copy link
Contributor

Added skip_propagate_down parameter as discussed with @jeffdonahue in #2054.

The parameter can be specified either 0 or N times, where N is the number of bottom blobs.
if skip_propagate_down[i] == True then nothing will be backpropagated to bottom[i].
If force_backward is specified, then skip_propagate_down has no effect.

Tests are included in this PR in test.net.cpp

@bhack
Copy link
Contributor

bhack commented Mar 13, 2015

@jeffdonahue I see that somebody is tagging PR as "ready for review". Can you tag also this one?

@bhack
Copy link
Contributor

bhack commented Mar 31, 2015

@jeffdonahue Can you pass here?

@@ -192,7 +192,8 @@ class Net {
/// @brief Append a new bottom blob to the net.
int AppendBottom(const NetParameter& param, const int layer_id,
const int bottom_id, set<string>* available_blobs,
map<string, int>* blob_name_to_idx);
map<string, int>* blob_name_to_idx,
bool skip_propagate = false);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no reason to make skip_propagate a new input -- just get it from layer_param in AppendBottom. (I don't think there should be any changes to Net::Init if you do it this way, but I might have overlooked something.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can change it if you want, but in this way this check needs to be done in the AppendBottom function, that it is called Bottom.size() times.
I know that this is not a computational relevant part, but don't you think that will be a little bit dirty?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leaving the check in Net::Init is fine (though I'd also be fine with moving it to AppendBottom). The rest of the logic is more natural to move to AppendBottom (and its signature shouldn't change) since it's associated specifically with a new bottom blob, and Net::Init is already longer than a single method should be.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I'll move the param retrieval into AppendBottom and I'll leave the check into Net::Init

@mtamburrano
Copy link
Contributor Author

@jeffdonahue I apported the changes you suggested:

  • AppendBottom doesn't take anymore additional params
  • At the end of Net::Init, when the graph is visited top-down, layer_need_backward_ is updated to be consistent with bottom_need_backward_. So if all the top blobs of a Layer don't need backprop, the Layer itself doesn't need back prop and his parents will notice it, to skip backprop themselves if each of their children will not propagate anything.
    In this way if a Layer has two children, with one of them able to backprop and the other not, the Layer still will be correctly needing backprop

@mtamburrano
Copy link
Contributor Author

hi @jeffdonahue, any news?

weiliu89 added a commit to weiliu89/caffe that referenced this pull request Apr 14, 2015
Added param skip_propagate_down to LayerParameter
// if propagate_down is true, the loss layer will try to
// backpropagate on labels
CHECK_EQ(need_back, true)
<< "bottom_need_backward should be True";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the CHECK_EQ(.., true)s in this test should be EXPECT_TRUE (and CHECK_EQ(..., false) -> EXPECT_FALSE) -- the tests should fail but not die if the behavior being tested is incorrect.

mtamburrano referenced this pull request in mtamburrano/caffe Apr 27, 2015
@bhack
Copy link
Contributor

bhack commented May 14, 2015

@jeffdonahue We want to program our activity to reserve a little bit of time for this. Do you need other changes or is it mergeable?

@jeffdonahue
Copy link
Contributor

LGTM -- please squash to a single commit and I'll merge. Thanks @mtamburrano!

@bhack
Copy link
Contributor

bhack commented May 15, 2015

Done

jeffdonahue added a commit that referenced this pull request May 15, 2015
Added param skip_propagate_down to LayerParameter
@jeffdonahue jeffdonahue merged commit e8d93cb into BVLC:master May 15, 2015
@jeffdonahue
Copy link
Contributor

Thanks @bhack and @mtamburrano!

@bhack
Copy link
Contributor

bhack commented May 15, 2015

Another brick in the (merge) wall :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants