Description:
I have been trying to build a simple linear regression model with the neural network with 4 features and one output. The loss function used is mse loss. It is returning loss as Nan. Learning rate is 1e-3.
I trying tuning the lr but I didn’t see any change in it. Would appreciate your help in the same.
Thanks in advance!
Training Loop
epochs=100
for epoch in range(epochs):
    for inputs,targets in training_data:
        y_pred=model(inputs.float())
        y_pred=y_pred.squeeze(1)
        #print(y_pred.shape)
        #print(inputs.dtype)
        #print(targets.dtype)
        #print(y_pred.dtype)
        y_pred=y_pred.double()
        loss=mse(y_pred,targets)
        loss.backward() #computing gradients
        opt.step() #updating parameters
        opt.zero_grad() #setting the grads back to zero
    if epoch%10==0:
        print(f'Epoch:{epoch}/{epochs} | Loss:{loss.item()}')

Output
Epoch:0/100 | Loss:nan
Epoch:10/100 | Loss:nan
Epoch:20/100 | Loss:nan
Epoch:30/100 | Loss:nan
Epoch:40/100 | Loss:nan
Epoch:50/100 | Loss:nan
Epoch:60/100 | Loss:nan
Epoch:70/100 | Loss:nan
Epoch:80/100 | Loss:nan
Epoch:90/100 | Loss:nan