Thank you very much. Indeed now the code runs.
However, I tried changing the loss function, with everything in the code being the same except now,

F.mse_loss(output, target)

and I get

AttributeError: ‘module’ object has no attribute ‘mse_loss’

but the documentation
http://pytorch.org/docs/master/nn.html 11
has

torch.nn.functional.mse_loss(input, target, size_average=True)[source]