29 #ifndef LBANN_CALLBACKS_VARIABLE_MINIBATCH_HPP_INCLUDED 30 #define LBANN_CALLBACKS_VARIABLE_MINIBATCH_HPP_INCLUDED 68 schedule(
model* m,
size_t& new_mbsize,
float& new_lr,
size_t& ramp_time) = 0;
96 step_minibatch(
size_t starting_mbsize,
size_t step,
size_t ramp_time = 0);
100 std::string
name()
const override {
return "step minibatch"; }
106 size_t& ramp_time)
override;
119 std::unique_ptr<callback_base>
121 std::shared_ptr<lbann_summary>
const&);
138 : epoch(_epoch), mbsize(_mbsize), lr(_lr), ramp_time(_ramp_time)
149 std::string
name()
const override {
return "minibatch schedule"; }
155 size_t& ramp_time)
override;
167 const google::protobuf::Message&,
168 std::shared_ptr<lbann_summary>
const&);
173 #endif // LBANN_CALLBACKS_VARIABLE_MINIBATCH_HPP_INCLUDED std::unique_ptr< callback_base > build_minibatch_schedule_callback_from_pbuf(const google::protobuf::Message &, std::shared_ptr< lbann_summary > const &)
step_minibatch * copy() const override
std::string name() const override
Return this callback's name.
float get_current_learning_rate(model *m) const
Get the current learning rate (assumes every layer has the same one).
std::vector< minibatch_step > m_steps
Steps in the mini-batch schedule, stored in reverse sorted order.
variable_minibatch & operator=(const variable_minibatch &)=default
float m_lr_incr
Amount to increment the learning rate by when ramping.
virtual bool schedule(model *m, size_t &new_mbsize, float &new_lr, size_t &ramp_time)=0
size_t m_ramp_count
Current number of epochs left to ramp the learning rate.
std::string name() const override
Return this callback's name.
std::unique_ptr< callback_base > build_step_minibatch_callback_from_pbuf(const google::protobuf::Message &, std::shared_ptr< lbann_summary > const &)
size_t m_ramp_time
Number of steps to ramp the learning rate over.
size_t mbsize
Mini-batch size to use.
size_t epoch
Epoch for this schedule to start.
Represents a step in a schedule of mini-batch sizes.
minibatch_step(size_t _epoch, size_t _mbsize, float _lr, size_t _ramp_time)
Base class for callbacks during training/testing.
Abstract base class for neural network models.
variable_minibatch(size_t starting_mbsize)
minibatch_schedule * copy() const override
size_t m_current_mini_batch_size
virtual void write_specific_proto(lbann_data::Callback &proto) const =0
Add callback specific data to prototext.
size_t m_step
Number of epochs between mini-batch size increases.
void change_learning_rate(model *m, float new_lr) const
Change the learning rate of every layer in m to new_lr.
float lr
Learning rate to use.
size_t ramp_time
Number of epochs to ramp the learning rate over.
size_t m_starting_mbsize
Initial mini-batch size.
void on_train_begin(model *m) override
Set the initial mini-batch size.
void on_epoch_end(model *m) override
Potentially change the mini-batch size.