Class: DNN::Activations::IdentityMAE

Inherits:
Layers::OutputLayer show all
Defined in:
lib/dnn/core/activations.rb

Instance Method Summary collapse

Methods inherited from Layers::Layer

#build, #built?, #initialize, #prev_layer, #shape, #to_hash

Constructor Details

This class inherits a constructor from DNN::Layers::Layer

Instance Method Details

#backward(y) ⇒ Object



92
93
94
95
96
97
# File 'lib/dnn/core/activations.rb', line 92

def backward(y)
  dout = @out - y
  dout[dout >= 0] = 1
  dout[dout < 0] = -1
  dout
end

#forward(x) ⇒ Object



88
89
90
# File 'lib/dnn/core/activations.rb', line 88

def forward(x)
  @out = x
end

#loss(y) ⇒ Object



99
100
101
102
# File 'lib/dnn/core/activations.rb', line 99

def loss(y)
  batch_size = y.shape[0]
  (@out - y).abs.sum / batch_size + ridge
end