Hi,
your code has a small issue regarding the shapes of y_pred and y.
When you check the sizes of these two Variables,
you will notice, that y_pred has a size of torch.size([6, 1]), while y has a size of torch.size([6]).
Subtracting these Variables results in a new Variable with size torch.size([6, 6]) due to broadcasting.
See the Release notes 10 for more information.
Your code should work when you change the following line:
loss = torch.mean((y - y_pred.view(-1))**2.0)