Class: DNN::Regularizers::Regularizer

Inherits:
Object
  • Object
show all
Defined in:
lib/dnn/core/regularizers.rb

Direct Known Subclasses

L1, L1L2, L2

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#paramObject

Returns the value of attribute param.



5
6
7
# File 'lib/dnn/core/regularizers.rb', line 5

def param
  @param
end

Class Method Details

.from_hash(hash) ⇒ Object

Raises:



7
8
9
10
11
12
13
14
# File 'lib/dnn/core/regularizers.rb', line 7

def self.from_hash(hash)
  return nil unless hash
  regularizer_class = DNN.const_get(hash[:class])
  regularizer = regularizer_class.allocate
  raise DNNError, "#{regularizer.class} is not an instance of #{self} class." unless regularizer.is_a?(self)
  regularizer.load_hash(hash)
  regularizer
end

Instance Method Details

#forward(x) ⇒ Object

Raises:

  • (NotImplementedError)


16
17
18
# File 'lib/dnn/core/regularizers.rb', line 16

def forward(x)
  raise NotImplementedError, "Class '#{self.class.name}' has implement method 'forward'"
end

#load_hash(hash) ⇒ Object

Raises:

  • (NotImplementedError)


26
27
28
# File 'lib/dnn/core/regularizers.rb', line 26

def load_hash(hash)
  raise NotImplementedError, "Class '#{self.class.name}' has implement method 'load_hash'"
end

#to_hash(merge_hash) ⇒ Object



20
21
22
23
24
# File 'lib/dnn/core/regularizers.rb', line 20

def to_hash(merge_hash)
  hash = { class: self.class.name }
  hash.merge!(merge_hash)
  hash
end