Skip to content

Commit

Permalink
Refactor solvers regularization and logging code
Browse files Browse the repository at this point in the history
  • Loading branch information
cypof authored and shelhamer committed May 27, 2015
1 parent c255709 commit ca81667
Show file tree
Hide file tree
Showing 2 changed files with 214 additions and 298 deletions.
12 changes: 7 additions & 5 deletions include/caffe/solver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ class Solver {
int iter() { return iter_; }

protected:
// Get the update value for the current iteration.
virtual void ComputeUpdateValue() = 0;
// Get and apply the update value for the current iteration.
virtual void MakeUpdate() = 0;
// The Solver::Snapshot function implements the basic snapshotting utility
// that stores the learned net. You should implement the SnapshotSolverState()
// function that produces a SolverState protocol buffer that needs to be
Expand Down Expand Up @@ -80,7 +80,9 @@ class SGDSolver : public Solver<Dtype> {
protected:
void PreSolve();
Dtype GetLearningRate();
virtual void ComputeUpdateValue();
virtual void MakeUpdate();
virtual void Regularize(int param_id);
virtual void ComputeUpdateValue(int param_id, Dtype rate);
virtual void ClipGradients();
virtual void SnapshotSolverState(SolverState * state);
virtual void RestoreSolverState(const SolverState& state);
Expand All @@ -102,7 +104,7 @@ class NesterovSolver : public SGDSolver<Dtype> {
: SGDSolver<Dtype>(param_file) {}

protected:
virtual void ComputeUpdateValue();
virtual void ComputeUpdateValue(int param_id, Dtype rate);

DISABLE_COPY_AND_ASSIGN(NesterovSolver);
};
Expand All @@ -116,7 +118,7 @@ class AdaGradSolver : public SGDSolver<Dtype> {
: SGDSolver<Dtype>(param_file) { constructor_sanity_check(); }

protected:
virtual void ComputeUpdateValue();
virtual void ComputeUpdateValue(int param_id, Dtype rate);
void constructor_sanity_check() {
CHECK_EQ(0, this->param_.momentum())
<< "Momentum cannot be used with AdaGrad.";
Expand Down
Loading

0 comments on commit ca81667

Please sign in to comment.