Class: DNN::Initializers::Const

Inherits:
Initializer show all
Defined in:
lib/dnn/core/initializers.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Initializer

from_hash

Constructor Details

#initialize(const) ⇒ Const

Returns a new instance of Const.

Parameters:

  • const (Float)

    Constant value of initialization.



48
49
50
51
# File 'lib/dnn/core/initializers.rb', line 48

def initialize(const)
  super()
  @const = const
end

Instance Attribute Details

#constObject (readonly)

Returns the value of attribute const.



45
46
47
# File 'lib/dnn/core/initializers.rb', line 45

def const
  @const
end

Instance Method Details

#init_param(layer, param) ⇒ Object



53
54
55
# File 'lib/dnn/core/initializers.rb', line 53

def init_param(layer, param)
  param.data = param.data.fill(@const)
end

#load_hash(hash) ⇒ Object



61
62
63
# File 'lib/dnn/core/initializers.rb', line 61

def load_hash(hash)
  initialize(hash[:const])
end

#to_hashObject



57
58
59
# File 'lib/dnn/core/initializers.rb', line 57

def to_hash
  super(const: @const)
end