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
#clean, from_hash, #load_hash, #loss, #regularizers_backward, #regularizers_forward, #to_hash
Instance Method Details
#backward(y, t) ⇒ Object
83
84
85
86
87
88
|
# File 'lib/dnn/core/losses.rb', line 83
def backward(y, t)
dy = y - t
dy[dy >= 0] = 1
dy[dy < 0] = -1
dy
end
|
#forward(y, t) ⇒ Object
78
79
80
81
|
# File 'lib/dnn/core/losses.rb', line 78
def forward(y, t)
batch_size = t.shape[0]
(y - t).abs.sum / batch_size
end
|