Class: DNN::Activations::SigmoidWithLoss
- Inherits:
-
OutputLayer
- Object
- DNN::Activations::SigmoidWithLoss
- Includes:
- SigmoidFunction, Numo
- Defined in:
- lib/dnn/core/activations.rb
Instance Method Summary collapse
Methods included from SigmoidFunction
Instance Method Details
#backward(y) ⇒ Object
118 119 120 |
# File 'lib/dnn/core/activations.rb', line 118 def backward(y) @out - y end |
#loss(y) ⇒ Object
122 123 124 125 |
# File 'lib/dnn/core/activations.rb', line 122 def loss(y) batch_size = y.shape[0] -(y * NMath.log(@out + 1e-7) + (1 - y) * NMath.log(1 - @out + 1e-7)).sum / batch_size + ridge end |