Class: DNN::Activations::IdentityMAE
Instance Method Summary
collapse
#build, #built?, #initialize, #prev_layer, #shape, #to_hash
Instance Method Details
#backward(y) ⇒ Object
165
166
167
168
169
170
|
# File 'lib/dnn/core/activations.rb', line 165
def backward(y)
dout = @out - y
dout[dout >= 0] = 1
dout[dout < 0] = -1
dout
end
|
#forward(x) ⇒ Object
161
162
163
|
# File 'lib/dnn/core/activations.rb', line 161
def forward(x)
@out = x
end
|
#loss(y) ⇒ Object
172
173
174
175
|
# File 'lib/dnn/core/activations.rb', line 172
def loss(y)
batch_size = y.shape[0]
(@out - y).abs.sum / batch_size + ridge
end
|