コード例 #1
0
ファイル: sgd_solver.cpp プロジェクト: fossabot/caffe
void SGDSolver<Dtype>::SnapshotSolverStateToBinaryProto(
    const string& model_filename) {
  SolverState state;
  state.set_iter(this->iter_);
  state.set_learned_net(model_filename);
  state.set_current_step(this->current_step_);
  state.clear_history();
  for (int i = 0; i < history_.size(); ++i) {
    // Add history
    BlobProto* history_blob = state.add_history();
    history_[i]->ToProto(history_blob);
  }
  string snapshot_filename = Solver<Dtype>::SnapshotFilename(".solverstate");
  LOG(INFO)
    << "Snapshotting solver state to binary proto file " << snapshot_filename;
  WriteProtoToBinaryFile(state, snapshot_filename.c_str());
}
コード例 #2
0
void Solver<Dtype>::Snapshot() {
	NetParameter net_param;
	// For intermediate results, we will also dump the gradient values.
	net_->ToProto(&net_param, param_.snapshot_diff());
	string filename(param_.snapshot_prefix());
	char iter_str_buffer[20];
	sprintf(iter_str_buffer, "_iter_%d", iter_);
	filename += iter_str_buffer;
	LOG(INFO)<< "Snapshotting to " << filename;
	WriteProtoToBinaryFile(net_param, filename.c_str());
	SolverState state;
	SnapshotSolverState(&state);
	state.set_iter(iter_);
	state.set_learned_net(filename);
	filename += ".solverstate";
	LOG(INFO)<< "Snapshotting solver state to " << filename;
	WriteProtoToBinaryFile(state, filename.c_str());
}
コード例 #3
0
ファイル: solver.cpp プロジェクト: VikingMew/dec
void Solver<Dtype>::Snapshot() {
  NetParameter net_param;
  // For intermediate results, we will also dump the gradient values.
  net_->ToProto(&net_param, param_.snapshot_diff());
  string filename(param_.snapshot_prefix());
  string model_filename, snapshot_filename;
  const int kBufferSize = 20;
  char iter_str_buffer[kBufferSize];
  snprintf(iter_str_buffer, kBufferSize, "_iter_%d", iter_);
  filename += iter_str_buffer;
  model_filename = filename + ".caffemodel";
  LOG(INFO) << "Snapshotting to " << model_filename;
  WriteProtoToBinaryFile(net_param, model_filename.c_str());
  SolverState state;
  SnapshotSolverState(&state);
  state.set_iter(iter_);
  state.set_learned_net(model_filename);
  snapshot_filename = filename + ".solverstate";
  LOG(INFO) << "Snapshotting solver state to " << snapshot_filename;
  WriteProtoToBinaryFile(state, snapshot_filename.c_str());
}