mse_loss¶
- paddle.nn.functional. mse_loss ( input, label, reduction='mean', name=None ) [source]
-
Accept input predications and label and returns the mean square error.
If
reduction
is set to'none'
, loss is calculated as:\[Out = (input - label)^2\]If
reduction
is set to'mean'
, loss is calculated as:\[Out = \operatorname{mean}((input - label)^2)\]If
reduction
is set to'sum'
, loss is calculated as:\[Out = \operatorname{sum}((input - label)^2)\]- Parameters
-
input (Tensor) – Input tensor, the data type should be float32 or float64.
label (Tensor) – Label tensor, the data type should be float32 or float64.
reduction (string, optional) – The reduction method for the output, could be ‘none’ | ‘mean’ | ‘sum’. If
reduction
is'mean'
, the reduced mean loss is returned. Ifreduction
is'sum'
, the reduced sum loss is returned. Ifreduction
is'none'
, the unreduced loss is returned. Default is'mean'
.name (str, optional) – Name for the operation (optional, default is None). For more information, please refer to Name.
- Returns
-
Tensor, The tensor tensor storing the mean square error difference of input and label.
Examples
>>> import paddle >>> mse_loss = paddle.nn.loss.MSELoss() >>> input = paddle.to_tensor(1.5) >>> label = paddle.to_tensor(1.7) >>> output = mse_loss(input, label) >>> print(output) Tensor(shape=[], dtype=float32, place=Place(cpu), stop_gradient=True, 0.04000002)