mean_squared_error

dragon.vm.tensorflow.keras.losses.mean_squared_error(
  y_true,
  y_pred,
  reduction='mean'
)[source]

Compute the reduced element-wise squared error.

The SquaredError function is defined as:

\[\text{SquaredError}(y_{true}, y_{pred}) = (y_{pred} - y_{true})^{2} \]

Examples:

y_true = tf.constant([1., 2., 3.])
y_pred = tf.constant([0., 0., 0.])
print(tf.keras.losses.mean_squared_error(y_true, y_pred))  # 4.666666
Parameters:
  • y_true (dragon.Tensor) – The ground truth tensor.
  • y_pred (dragon.Tensor) – The logits tensor.
  • reduction ({'none', 'sum', 'mean'}, optional) – The reduction method.
Returns:

dragon.Tensor – The loss.