Class: DNN::Initializers::RandomNormal

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#meanObject (readonly)

Returns the value of attribute mean.



51
52
53
# File 'lib/dnn/core/initializers.rb', line 51

def mean
  @mean
end

#stdObject (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_hashObject



69
70
71
# File 'lib/dnn/core/initializers.rb', line 69

def to_hash
  super({mean: @mean, std: @std})
end