Please help Training Loss and Test Loss is NAN

Hello Team,

I am trying to solve a regression problem of predicting house using pytorch linear model
=House-Price-Pytorch-V2 | Kaggle

The tensors look okay to me for test and train split but while training the model loss for test and train is coming as NAN.

Let me know how to correct this error.

Is the loss immediately NaN upon the first iteration (before any weight updates)? I would inspect the intermediate outputs of the model and see where the first NaN originates. You may want to use a utility function like torch.isfinite — PyTorch 2.0 documentation to help with this.

If the loss doesn’t start out as NaN but becomes NaN after some iterations, I would check the learning rate schedule of your optimizer and see if decreasing the learning rate helps.

The model is starting with NaN from the beginning