Class: DNN::Losses::Loss
- Inherits:
-
Object
show all
- Defined in:
- lib/dnn/core/losses.rb
Instance Method Summary
collapse
Instance Method Details
#backward(y) ⇒ Object
16
17
18
|
# File 'lib/dnn/core/losses.rb', line 16
def backward(y)
raise NotImplementedError.new("Class '#{self.class.name}' has implement method 'backward'")
end
|
#forward(out, y, layers) ⇒ Object
5
6
7
8
9
10
11
12
13
14
|
# File 'lib/dnn/core/losses.rb', line 5
def forward(out, y, layers)
loss_value = loss(out, y)
regularizers = layers.select { |layer| layer.is_a?(Connection) }
.map { |layer| layer.regularizers }.flatten
regularizers.each do |regularizer|
loss_value = regularizer.forward(loss_value)
end
loss_value
end
|
#regularizes_backward(layers) ⇒ Object
20
21
22
23
24
25
26
|
# File 'lib/dnn/core/losses.rb', line 20
def regularizes_backward(layers)
layers.select { |layer| layer.is_a?(Connection) }.each do |layer|
layer.regularizers.each do |regularizer|
regularizer.backward
end
end
end
|
#to_hash ⇒ Object
28
29
30
|
# File 'lib/dnn/core/losses.rb', line 28
def to_hash
{class: self.class.name}
end
|