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
9
10
11
|
# File 'lib/dnn/core/losses.rb', line 9
def backward(y)
raise NotImplementedError.new("Class '#{self.class.name}' has implement method 'backward'")
end
|
#d_regularize(layers) ⇒ Object
18
19
20
21
22
23
|
# File 'lib/dnn/core/losses.rb', line 18
def d_regularize(layers)
layers.select { |layer| layer.is_a?(Connection) }.each do |layer|
layer.d_lasso
layer.d_ridge
end
end
|
#forward(out, y) ⇒ Object
5
6
7
|
# File 'lib/dnn/core/losses.rb', line 5
def forward(out, y)
raise NotImplementedError.new("Class '#{self.class.name}' has implement method 'forward'")
end
|
#regularize(layers) ⇒ Object
13
14
15
16
|
# File 'lib/dnn/core/losses.rb', line 13
def regularize(layers)
layers.select { |layer| layer.is_a?(Connection) }
.reduce(0) { |sum, layer| sum + layer.lasso + layer.ridge }
end
|
#to_hash ⇒ Object
25
26
27
|
# File 'lib/dnn/core/losses.rb', line 25
def to_hash
{class: self.class.name}
end
|