Class: DNN::Activations::IdentityMAE
Instance Method Summary
collapse
#build, #built?, #initialize, #prev_layer, #shape, #to_hash
Instance Method Details
#backward(y) ⇒ Object
116
117
118
119
120
121
|
# File 'lib/dnn/core/activations.rb', line 116
def backward(y)
dout = @out - y
dout[dout >= 0] = 1
dout[dout < 0] = -1
dout
end
|
#forward(x) ⇒ Object
112
113
114
|
# File 'lib/dnn/core/activations.rb', line 112
def forward(x)
@out = x
end
|
#loss(y) ⇒ Object
123
124
125
126
|
# File 'lib/dnn/core/activations.rb', line 123
def loss(y)
batch_size = y.shape[0]
(@out - y).abs.sum / batch_size + ridge
end
|