mse_loss¶
- paddle.nn.functional. mse_loss ( input, label, reduction='mean', name=None ) [source]
-
This op accepts input predications and label and returns the mean square error.
If
reductionis set to'none', loss is calculated as:\[Out = (input - label)^2\]If
reductionis set to'mean', loss is calculated as:\[Out = \operatorname{mean}((input - label)^2)\]If
reductionis 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
reductionis'mean', the reduced mean loss is returned. Ifreductionis'sum', the reduced sum loss is returned. Ifreductionis'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
-
The tensor tensor storing the mean square error difference of input and label.
- Return type
-
Tensor
Return type: Tensor.
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) # [0.04000002]
