MSELoss from Pytorch

Viewed 897

I am trying to train a neural network using Pytorch. I would like the loss function to be the MSE. I tried to use torch.nn.MSELoss, however I get an error that I do not understand.

For example the following code gives me RuntimeError: Boolean value of Tensor with more than one value is ambiguous

import torch
import torch.nn as nn

model = torch.zeros(64)
model.requires_grad = True
target = torch.ones(64)

loss = nn.MSELoss(model, target)

Any help will be very much appreciated!

1 Answers
Related