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) ⇒ RandomNormal

Returns a new instance of RandomNormal.



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

def initialize(mean = 0, std = 0.05)
  @mean = mean
  @std = std
end

Instance Attribute Details

#mean ⇒ Object (readonly)

Returns the value of attribute mean.



45
46
47
# File 'lib/dnn/core/initializers.rb', line 45

def mean
  @mean
end

#std ⇒ Object (readonly)

Returns the value of attribute std.



46
47
48
# File 'lib/dnn/core/initializers.rb', line 46

def std
  @std
end

Class Method Details

.load_hash(hash) ⇒ Object



48
49
50
# File 'lib/dnn/core/initializers.rb', line 48

def self.load_hash(hash)
  self.new(hash[:mean], hash[:std])
end

Instance Method Details

#init_param(layer, param) ⇒ Object



57
58
59
# File 'lib/dnn/core/initializers.rb', line 57

def init_param(layer, param)
  param.data = param.data.rand_norm(@mean, @std)
end

#to_hash ⇒ Object



61
62
63
# File 'lib/dnn/core/initializers.rb', line 61

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