Class: Chainer::HyperparameterProxy

Inherits:
Object
  • Object
show all
Defined in:
lib/chainer/optimizer.rb

Instance Method Summary collapse

Constructor Details

#initialize(obj, attr_name) ⇒ HyperparameterProxy

Returns a new instance of HyperparameterProxy.



140
141
142
143
144
145
146
147
148
149
150
# File 'lib/chainer/optimizer.rb', line 140

def initialize(obj, attr_name)
  obj.class.class_eval do
    obj.class.send(:define_method, attr_name) do
      self.instance_variable_get(:@hyperparam).instance_variable_get("@#{attr_name}")
    end

    obj.class.send(:define_method, "#{attr_name}=") do |val|
      self.instance_variable_get(:@hyperparam).instance_variable_set("@#{attr_name}", val)
    end
  end
end