Class: DNN::Losses::SigmoidCrossEntropy
- Inherits:
-
Loss
- Object
- Loss
- DNN::Losses::SigmoidCrossEntropy
show all
- Defined in:
- lib/dnn/core/losses.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Loss
#loss, #regularizers_backward, #regularizers_forward
Constructor Details
Returns a new instance of SigmoidCrossEntropy.
155
156
157
|
# File 'lib/dnn/core/losses.rb', line 155
def initialize(eps: 1e-7)
@eps = eps
end
|
Instance Attribute Details
#eps ⇒ Object
Returns the value of attribute eps.
148
149
150
|
# File 'lib/dnn/core/losses.rb', line 148
def eps
@eps
end
|
Class Method Details
.from_hash(hash) ⇒ Object
150
151
152
|
# File 'lib/dnn/core/losses.rb', line 150
def self.from_hash(hash)
self.new(eps: hash[:eps])
end
|
Instance Method Details
#backward(y, t) ⇒ Object
164
165
166
|
# File 'lib/dnn/core/losses.rb', line 164
def backward(y, t)
@x - t
end
|
#forward(y, t) ⇒ Object
159
160
161
162
|
# File 'lib/dnn/core/losses.rb', line 159
def forward(y, t)
@x = Activations::Sigmoid.new.forward(y)
-(t * Xumo::NMath.log(@x) + (1 - t) * Xumo::NMath.log(1 - @x))
end
|
#to_hash ⇒ Object
168
169
170
|
# File 'lib/dnn/core/losses.rb', line 168
def to_hash
super(eps: @eps)
end
|