Class: DNN::Losses::Hinge
Instance Method Summary
collapse
#forward
Methods inherited from Loss
call, #call, #clean, #forward, from_hash, #load_hash, #loss, #regularizers_forward, #to_hash
Instance Method Details
#backward_node(d) ⇒ Object
104
105
106
107
108
|
# File 'lib/dnn/core/losses.rb', line 104
def backward_node(d)
a = Xumo::SFloat.ones(*@a.shape)
a[@a <= 0] = 0
d * (a * -@t) / a.shape[0]
end
|
#forward_node(y, t) ⇒ Object
98
99
100
101
102
|
# File 'lib/dnn/core/losses.rb', line 98
def forward_node(y, t)
@t = t
@a = 1 - y * t
Xumo::SFloat.maximum(0, @a).mean(0).sum
end
|