Class: DNN::Activations::IdentityHuber

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



200
201
202
203
204
205
206
207
# File 'lib/dnn/core/activations.rb', line 200

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

#forward(x) ⇒ Object



190
191
192
# File 'lib/dnn/core/activations.rb', line 190

def forward(x)
  @out = x
end

#loss(y) ⇒ Object



194
195
196
197
198
# File 'lib/dnn/core/activations.rb', line 194

def loss(y)
  loss = loss_l1(y)
  loss = loss > 1 ? loss : loss_l2(y)
  @loss = loss + lasso + ridge
end