Class: DNN::Initializers::Initializer
- Inherits:
-
Object
- Object
- DNN::Initializers::Initializer
show all
- Defined in:
- lib/dnn/core/initializers.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(seed: false) ⇒ Initializer
Returns a new instance of Initializer.
16
17
18
|
# File 'lib/dnn/core/initializers.rb', line 16
def initialize(seed: false)
@seed = seed == true ? rand(1 << 31) : seed
end
|
Class Method Details
.from_hash(hash) ⇒ Object
5
6
7
8
9
10
11
12
|
# File 'lib/dnn/core/initializers.rb', line 5
def self.from_hash(hash)
return nil unless hash
initializer_class = DNN.const_get(hash[:class])
initializer = initializer_class.allocate
raise DNNError, "#{initializer.class} is not an instance of #{self} class." unless initializer.is_a?(self)
initializer.load_hash(hash)
initializer
end
|
Instance Method Details
#init_param(layer, param) ⇒ Object
Initialization of learning parameters.
23
24
25
|
# File 'lib/dnn/core/initializers.rb', line 23
def init_param(layer, param)
raise NotImplementedError, "Class '#{self.class.name}' has implement method 'init_param'"
end
|
#load_hash(hash) ⇒ Object
33
34
35
|
# File 'lib/dnn/core/initializers.rb', line 33
def load_hash(hash)
initialize
end
|
#to_hash(merge_hash = nil) ⇒ Object
27
28
29
30
31
|
# File 'lib/dnn/core/initializers.rb', line 27
def to_hash(merge_hash = nil)
hash = { class: self.class.name, seed: @seed }
hash.merge!(merge_hash) if merge_hash
hash
end
|