Class: DNN::Losses::MeanAbsoluteError

Inherits:
Loss
  • Object
show all
Includes:
DNN::Layers::LayerNode
Defined in:
lib/dnn/core/losses.rb

Instance Method Summary collapse

Methods included from DNN::Layers::LayerNode

#forward

Methods inherited from Loss

call, #call, #clean, #forward, from_hash, #load_hash, #loss, #regularizers_forward, #to_hash

Instance Method Details

#backward_node(d) ⇒ Object



87
88
89
90
91
92
# File 'lib/dnn/core/losses.rb', line 87

def backward_node(d)
  dy = (@y - @t)
  dy[dy >= 0] = 1
  dy[dy < 0] = -1
  d * dy / @y.shape[0]
end

#forward_node(y, t) ⇒ Object



81
82
83
84
85
# File 'lib/dnn/core/losses.rb', line 81

def forward_node(y, t)
  @y = y
  @t = t
  (y - t).abs.mean(0).sum
end