Skip to content

Commit

Permalink
Merge pull request microsoft#35 from slayton58/reshape_fix
Browse files Browse the repository at this point in the history
Reshape Layers before calling Forward / Backward
  • Loading branch information
lukeyeager committed Nov 20, 2015
2 parents 9852ff8 + f0b8e81 commit a8cf019
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/caffe/net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,7 @@ Dtype Net<Dtype>::ForwardFromTo(int start, int end) {
}
for (int i = start; i <= end; ++i) {
// LOG(ERROR) << "Forwarding " << layer_names_[i];
layers_[i]->Reshape(bottom_vecs_[i], top_vecs_[i]);
Dtype layer_loss = layers_[i]->Forward(bottom_vecs_[i], top_vecs_[i]);
loss += layer_loss;
if (debug_info_) { ForwardDebugInfo(i); }
Expand Down Expand Up @@ -617,6 +618,7 @@ void Net<Dtype>::BackwardFromTo(int start, int end) {
CHECK_LT(start, layers_.size());
for (int i = start; i >= end; --i) {
if (layer_need_backward_[i]) {
layers_[i]->Reshape(bottom_vecs_[i], top_vecs_[i]);
layers_[i]->Backward(
top_vecs_[i], bottom_need_backward_[i], bottom_vecs_[i]);
if (debug_info_) { BackwardDebugInfo(i); }
Expand Down

0 comments on commit a8cf019

Please sign in to comment.