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