I encountered this error when computing MSE using a trained model. The related codes are as follows:
for j in range(5):

    a = torch.randn(40, 8)
    pred = net(a)
    loss = ((pred - y_train)**2).mean()

    train_and_eval(trainloader, testloader, lr, optimizer, loss_func, net, y_test, Epoch = 1)

It seems that when I use pred, it will throw an error(even when I just print it). How can I fix this?