facebookarchive / caffe2

Caffe2 is a lightweight, modular, and scalable deep learning framework.
https://caffe2.ai
Apache License 2.0
8.42k stars 1.94k forks source link

caffe2: How to set learning rate policy as a "multistep" mode. #1860

Open shieldOnTheRoad opened 6 years ago

shieldOnTheRoad commented 6 years ago

Please help, when I set the policy="multistep" in model.net.LearningRate(...), I'm getting the following error.

F0201 14:09:26.101269  6743 learning_rate_op.h:110] Unknown learning rate policy: multistep

Could anyone do me favor to solver this problem ? Thanks for reading. Some details of lr_policy in caffe2/caffe/proto/caffe.proto are showed as follows.

  // The learning rate decay policy. The currently implemented learning rate
  // policies are as follows:
  //    - fixed: always return base_lr.
  //    - step: return base_lr * gamma ^ (floor(iter / step))
  //    - exp: return base_lr * gamma ^ iter
  //    - inv: return base_lr * (1 + gamma * iter) ^ (- power)
  //    - multistep: similar to step but it allows non uniform steps defined by
  //      stepvalue
  //    - poly: the effective learning rate follows a polynomial decay, to be
  //      zero by the max_iter. return base_lr (1 - iter/max_iter) ^ (power)
  //    - sigmoid: the effective learning rate follows a sigmod decay
  //      return base_lr ( 1/(1 + exp(-gamma * (iter - stepsize))))
  //
  // where base_lr, max_iter, gamma, step, stepvalue and power are defined
  // in the solver parameter protocol buffer, and iter is the current iteration.
  optional string lr_policy = 8;
  optional float gamma = 9; // The parameter to compute the learning rate.
  optional float power = 10; // The parameter to compute the learning rate.
  optional float momentum = 11; // The momentum value.
  optional float weight_decay = 12; // The weight decay.
  // regularization types supported: L1 and L2
  // controlled by weight_decay
  optional string regularization_type = 29 [default = "L2"];
  // the stepsize for learning rate policy "step"
  optional int32 stepsize = 13;
  // the stepsize for learning rate policy "multistep"
  repeated int32 stepvalue = 34;
slayton58 commented 6 years ago

That's because that's a learning rate policy defined in Caffe, not Caffe2.

I do have an implementation of a multistep policy locally that I could PR if you wanted it.

BIGBALLON commented 6 years ago

hi @slayton58, can you show us how to do "multistep" in caffe2, I think it is a useful policy in classification task.