Skip to content

Commit

Permalink
Add solver resumption (fix BVLC#6)
Browse files Browse the repository at this point in the history
One can now specify trained_layers in the solver prototext and have the net simply continue training the layers with those predefined weights.
  • Loading branch information
aidangomez committed Jul 20, 2015
1 parent bac50b0 commit 6f8a0cc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/caffe/proto/caffe.proto
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ message NetParameter {
// NOTE
// Update the next available ID when you add a new SolverParameter field.
//
// SolverParameter next available ID: 37 (last added: iter_size)
// SolverParameter next available ID: 38 (last added: trained_layers)
message SolverParameter {
//////////////////////////////////////////////////////////////////////////////
// Specifying the train and test networks
Expand All @@ -115,6 +115,7 @@ message SolverParameter {
// Proto filename for the train net, possibly combined with one or more
// test nets.
optional string net = 24;
optional string trained_layers = 37;
// Inline train net param, possibly combined with one or more test nets.
optional NetParameter net_param = 25;

Expand Down
4 changes: 4 additions & 0 deletions src/caffe/solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ void Solver<Dtype>::InitTrainNet() {
net_state.MergeFrom(param_.train_state());
net_param.mutable_state()->CopyFrom(net_state);
net_.reset(new Net<Dtype>(net_param));

if (param_.has_trained_layers()) {
net_->CopyTrainedLayersFrom(param_.trained_layers());
}
}

template <typename Dtype>
Expand Down

0 comments on commit 6f8a0cc

Please sign in to comment.