mse_loss
- paddle.nn.functional. mse_loss ( input: Tensor, label: Tensor, reduction: _ReduceMode = 'mean', name: str | None = None ) Tensor [source]
-
Accept 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 api_guide_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)
