class RANN::Optimisers::RMSProp

Public Class Methods

new(opts = {}) click to toggle source
# File lib/rann/optimisers/rmsprop.rb, line 8
def initialize opts = {}
  @decay               = opts[:decay] || 0.9.to_d
  @fudge_factor        = opts[:fudge_factor] || 0.00000001.to_d
  @learning_rate       = opts[:learning_rate] || 0.01.to_d
  @historical_gradient = {}.tap{ |h| h.default = 0.to_d }
end

Public Instance Methods

load_state(state) click to toggle source
# File lib/rann/optimisers/rmsprop.rb, line 28
def load_state state
  state.each do |name, value|
    instance_variable_set("@#{name}", value)
  end
end
state() click to toggle source

anything that gets modified over the course of training

# File lib/rann/optimisers/rmsprop.rb, line 22
def state
  {
    historical_gradient: @historical_gradient,
  }
end
update(grad, cid) click to toggle source
# File lib/rann/optimisers/rmsprop.rb, line 15
def update grad, cid
  @historical_gradient[cid] = @decay * @historical_gradient[cid] + (1 - @decay) * grad ** 2

  grad * - @learning_rate / (@fudge_factor + @historical_gradient[cid].sqrt(0))
end