Class: DNN::Losses::MeanSquaredError

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



73
74
75
# File 'lib/dnn/core/losses.rb', line 73

def backward_node(d)
  d * (@y - @t) / @y.shape[0]
end

#forward_node(y, t) ⇒ Object



67
68
69
70
71
# File 'lib/dnn/core/losses.rb', line 67

def forward_node(y, t)
  @y = y
  @t = t
  0.5 * ((y - t)**2).mean(0).sum
end