Class: DNN::Losses::MeanSquaredError

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

Instance Method Summary collapse

Methods inherited from Loss

from_hash, #load_hash, #loss, #regularizers_backward, #regularizers_forward, #to_hash

Instance Method Details

#backward(y, t) ⇒ Object



64
65
66
# File 'lib/dnn/core/losses.rb', line 64

def backward(y, t)
  y - t
end

#forward(y, t) ⇒ Object



59
60
61
62
# File 'lib/dnn/core/losses.rb', line 59

def forward(y, t)
  batch_size = t.shape[0]
  0.5 * ((y - t)**2).sum / batch_size
end