Class: Torch::Optim::LRScheduler::ExponentialLR

Inherits:
LRScheduler
  • Object
show all
Defined in:
lib/torch/optim/lr_scheduler/exponential_lr.rb

Instance Method Summary collapse

Methods inherited from LRScheduler

#step

Constructor Details

#initialize(optimizer, gamma, last_epoch: -1)) ⇒ ExponentialLR

Returns a new instance of ExponentialLR.



5
6
7
8
# File 'lib/torch/optim/lr_scheduler/exponential_lr.rb', line 5

def initialize(optimizer, gamma, last_epoch: -1)
  @gamma = gamma
  super(optimizer, last_epoch)
end

Instance Method Details

#get_lrObject



10
11
12
13
14
15
16
17
18
# File 'lib/torch/optim/lr_scheduler/exponential_lr.rb', line 10

def get_lr
  if @last_epoch == 0
    @base_lrs
  else
    @optimizer.param_groups.map do |group|
      group[:lr] * @gamma
    end
  end
end