Creates a criterion that measures the mean squared error (squared L2 norm) between
each element in the input reduction
set to 'none'
) loss can be described
as:
Details
where reduction
is not 'none'
(default 'mean'
), then:
The mean operation still operates over all the elements, and divides by reduction = 'sum'
.
Examples
if (torch_is_installed()) {
loss <- nn_mse_loss()
input <- torch_randn(3, 5, requires_grad = TRUE)
target <- torch_randn(3, 5)
output <- loss(input, target)
output$backward()
}