Class: DNN::Initializers::RandomNormal
- Inherits:
-
Initializer
- Object
- Initializer
- DNN::Initializers::RandomNormal
- Defined in:
- lib/dnn/core/initializers.rb
Instance Attribute Summary collapse
-
#mean ⇒ Object
readonly
Returns the value of attribute mean.
-
#std ⇒ Object
readonly
Returns the value of attribute std.
Class Method Summary collapse
Instance Method Summary collapse
- #init_param(layer, param) ⇒ Object
-
#initialize(mean = 0, std = 0.05, seed = true) ⇒ RandomNormal
constructor
A new instance of RandomNormal.
- #to_hash ⇒ Object
Constructor Details
#initialize(mean = 0, std = 0.05, seed = true) ⇒ RandomNormal
Returns a new instance of RandomNormal.
58 59 60 61 62 |
# File 'lib/dnn/core/initializers.rb', line 58 def initialize(mean = 0, std = 0.05, seed = true) super(seed) @mean = mean @std = std end |
Instance Attribute Details
#mean ⇒ Object (readonly)
Returns the value of attribute mean.
51 52 53 |
# File 'lib/dnn/core/initializers.rb', line 51 def mean @mean end |
#std ⇒ Object (readonly)
Returns the value of attribute std.
52 53 54 |
# File 'lib/dnn/core/initializers.rb', line 52 def std @std end |
Class Method Details
.load_hash(hash) ⇒ Object
54 55 56 |
# File 'lib/dnn/core/initializers.rb', line 54 def self.load_hash(hash) self.new(hash[:mean], hash[:std], hash[:seed]) end |
Instance Method Details
#init_param(layer, param) ⇒ Object
64 65 66 67 |
# File 'lib/dnn/core/initializers.rb', line 64 def init_param(layer, param) Xumo::SFloat.srand(@seed) param.data = param.data.rand_norm(@mean, @std) end |
#to_hash ⇒ Object
69 70 71 |
# File 'lib/dnn/core/initializers.rb', line 69 def to_hash super({mean: @mean, std: @std}) end |