Class: Torch::Optim::LRScheduler::StepLR

Inherits:
Torch::Optim::LRScheduler show all
Defined in:
lib/torch/optim/lr_scheduler/step_lr.rb

Instance Method Summary collapse

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_lrObject



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