Class: Torch::Optim::LRScheduler::StepLR
- Inherits:
-
Torch::Optim::LRScheduler
- Object
- Torch::Optim::LRScheduler
- Torch::Optim::LRScheduler::StepLR
- Defined in:
- lib/torch/optim/lr_scheduler/step_lr.rb
Instance Method Summary collapse
- #get_lr ⇒ Object
-
#initialize(optimizer, step_size:, gamma: 0.1, last_epoch: -1)) ⇒ StepLR
constructor
A new instance of StepLR.
Constructor Details
#initialize(optimizer, step_size:, gamma: 0.1, last_epoch: -1)) ⇒ StepLR
Returns a new instance of StepLR.
5 6 7 8 9 |
# File 'lib/torch/optim/lr_scheduler/step_lr.rb', line 5 def initialize(optimizer, step_size:, gamma: 0.1, last_epoch: -1) @step_size = step_size @gamma = gamma super(optimizer, last_epoch) end |
Instance Method Details
#get_lr ⇒ Object
11 12 13 |
# File 'lib/torch/optim/lr_scheduler/step_lr.rb', line 11 def get_lr @base_lrs.map { |base_lr| base_lr * @gamma ** (@last_epoch / @step_size).floor } end |