Class: DNN::Activations::IdentityMAE
Instance Method Summary
collapse
#build, #built?, #initialize, #prev_layer, #shape, #to_hash
Instance Method Details
#backward(y) ⇒ Object
93
94
95
96
97
98
|
# File 'lib/dnn/core/activations.rb', line 93
def backward(y)
dout = @out - y
dout[dout >= 0] = 1
dout[dout < 0] = -1
dout
end
|
#forward(x) ⇒ Object
89
90
91
|
# File 'lib/dnn/core/activations.rb', line 89
def forward(x)
@out = x
end
|
#loss(y) ⇒ Object
100
101
102
103
|
# File 'lib/dnn/core/activations.rb', line 100
def loss(y)
batch_size = y.shape[0]
(@out - y).abs.sum / batch_size + ridge
end
|