Class: DNN::Losses::MeanSquaredError

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

Instance Method Summary collapse

Methods inherited from Loss

#loss, #regularizers_backward, #regularizers_forward, #to_hash

Instance Method Details

#backward(y, t) ⇒ Object



51
52
53
# File 'lib/dnn/core/losses.rb', line 51

def backward(y, t)
  y - t
end

#forward(y, t) ⇒ Object



46
47
48
49
# File 'lib/dnn/core/losses.rb', line 46

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