Class: DNN::Initializers::RandomUniform
- Inherits:
-
Initializer
- Object
- Initializer
- DNN::Initializers::RandomUniform
- Defined in:
- lib/dnn/core/initializers.rb
Instance Attribute Summary collapse
-
#max ⇒ Object
readonly
Returns the value of attribute max.
-
#min ⇒ Object
readonly
Returns the value of attribute min.
Instance Method Summary collapse
- #init_param(layer, param) ⇒ Object
-
#initialize(min = -0.05,, max = 0.05, seed: true) ⇒ RandomUniform
constructor
A new instance of RandomUniform.
- #load_hash(hash) ⇒ Object
- #to_hash ⇒ Object
Methods inherited from Initializer
Constructor Details
#initialize(min = -0.05,, max = 0.05, seed: true) ⇒ RandomUniform
Returns a new instance of RandomUniform.
102 103 104 105 106 |
# File 'lib/dnn/core/initializers.rb', line 102 def initialize(min = -0.05, max = 0.05, seed: true) super(seed: seed) @min = min @max = max end |
Instance Attribute Details
#max ⇒ Object (readonly)
Returns the value of attribute max.
98 99 100 |
# File 'lib/dnn/core/initializers.rb', line 98 def max @max end |
#min ⇒ Object (readonly)
Returns the value of attribute min.
97 98 99 |
# File 'lib/dnn/core/initializers.rb', line 97 def min @min end |
Instance Method Details
#init_param(layer, param) ⇒ Object
108 109 110 111 |
# File 'lib/dnn/core/initializers.rb', line 108 def init_param(layer, param) Xumo::SFloat.srand(@seed) param.data = param.data.rand(@min, @max) end |
#load_hash(hash) ⇒ Object
117 118 119 |
# File 'lib/dnn/core/initializers.rb', line 117 def load_hash(hash) initialize(hash[:min], hash[:max], seed: hash[:seed]) end |
#to_hash ⇒ Object
113 114 115 |
# File 'lib/dnn/core/initializers.rb', line 113 def to_hash super(min: @min, max: @max) end |