Class: DNN::Losses::MeanAbsoluteError
- Inherits:
-
Loss
- Object
- Loss
- DNN::Losses::MeanAbsoluteError
show all
- Defined in:
- lib/dnn/core/losses.rb
Instance Method Summary
collapse
Methods inherited from Loss
#d_regularize, #regularize, #to_hash
Instance Method Details
#backward(y) ⇒ Object
50
51
52
53
54
55
|
# File 'lib/dnn/core/losses.rb', line 50
def backward(y)
dout = @out - y
dout[dout >= 0] = 1
dout[dout < 0] = -1
dout
end
|
#forward(out, y) ⇒ Object
44
45
46
47
48
|
# File 'lib/dnn/core/losses.rb', line 44
def forward(out, y)
@out = out
batch_size = y.shape[0]
(out - y).abs.sum / batch_size
end
|