Class: DNN::Losses::SoftmaxCrossEntropy
- Inherits:
-
Loss
- Object
- Loss
- DNN::Losses::SoftmaxCrossEntropy
show all
- Defined in:
- lib/dnn/core/losses.rb
Constant Summary
collapse
- NMath =
Xumo::NMath
Instance Method Summary
collapse
Methods inherited from Loss
#d_regularize, #regularize, #to_hash
Instance Method Details
#backward(y) ⇒ Object
99
100
101
|
# File 'lib/dnn/core/losses.rb', line 99
def backward(y)
@out - y
end
|
#forward(x, y) ⇒ Object
93
94
95
96
97
|
# File 'lib/dnn/core/losses.rb', line 93
def forward(x, y)
@out = Utils.softmax(x)
batch_size = y.shape[0]
-(y * NMath.log(@out + 1e-7)).sum / batch_size
end
|