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.
Class Method Summary collapse
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.
- #to_hash ⇒ Object
Constructor Details
#initialize(min = -0.05,, max = 0.05, seed = true) ⇒ RandomUniform
Returns a new instance of RandomUniform.
83 84 85 86 87 |
# File 'lib/dnn/core/initializers.rb', line 83 def initialize(min = -0.05, max = 0.05, seed = true) super(seed) @min = min @max = max end |
Instance Attribute Details
#max ⇒ Object (readonly)
Returns the value of attribute max.
77 78 79 |
# File 'lib/dnn/core/initializers.rb', line 77 def max @max end |
#min ⇒ Object (readonly)
Returns the value of attribute min.
76 77 78 |
# File 'lib/dnn/core/initializers.rb', line 76 def min @min end |
Class Method Details
.load_hash(hash) ⇒ Object
79 80 81 |
# File 'lib/dnn/core/initializers.rb', line 79 def self.load_hash(hash) self.new(hash[:min], hash[:max], hash[:seed]) end |
Instance Method Details
#init_param(layer, param) ⇒ Object
89 90 91 92 |
# File 'lib/dnn/core/initializers.rb', line 89 def init_param(layer, param) Xumo::SFloat.srand(@seed) param.data = param.data.rand(@min, @max) end |
#to_hash ⇒ Object
94 95 96 |
# File 'lib/dnn/core/initializers.rb', line 94 def to_hash super({min: @min, max: @max}) end |