It seems you are trying to pass a numpy array to F.nll_loss, while a PyTorch tensor is expected.
I’m not sure how y_pred is calculated, but note that using numpy array would detach them from the computation graph, so you should stick to PyTorch tensors and operations, if possible.