Class: DNN::Initializers::He

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

Instance Method Summary collapse

Methods inherited from Initializer

from_hash, #load_hash, #to_hash

Constructor Details

#initialize(seed: true) ⇒ He

Returns a new instance of He.



131
132
133
# File 'lib/dnn/core/initializers.rb', line 131

def initialize(seed: true)
  super
end

Instance Method Details

#init_param(layer, param) ⇒ Object



135
136
137
138
139
# File 'lib/dnn/core/initializers.rb', line 135

def init_param(layer, param)
  Xumo::SFloat.srand(@seed)
  num_prev_units = layer.input_shape.reduce(:*)
  param.data = param.data.rand_norm / Math.sqrt(num_prev_units) * Math.sqrt(2)
end