Errors during Assignment 2

/usr/local/lib/python3.6/dist-packages/ipykernel_launcher.py:15: UserWarning: Using a target size (torch.Size([24, 1])) that is different to the input size (torch.Size([24])). This will likely lead to incorrect results due to broadcasting. Please ensure they have the same size.
from ipykernel import kernelapp as app
/usr/local/lib/python3.6/dist-packages/ipykernel_launcher.py:15: UserWarning: Using a target size (torch.Size([16, 1])) that is different to the input size (torch.Size([16])). This will likely lead to incorrect results due to broadcasting. Please ensure they have the same size.
from ipykernel import kernelapp as app
/usr/local/lib/python3.6/dist-packages/ipykernel_launcher.py:23: UserWarning: Using a target size (torch.Size([24, 1])) that is different to the input size (torch.Size([24])). This will likely lead to incorrect results due to broadcasting. Please ensure they have the same size.
/usr/local/lib/python3.6/dist-packages/ipykernel_launcher.py:23: UserWarning: Using a target size (torch.Size([7, 1])) that is different to the input size (torch.Size([7])). This will likely lead to incorrect results due to broadcasting. Please ensure they have the same size.

I got this huge list of errors. Please read and help. I tried searching for solution but couldn’t find anything elsewhere.

There is only a single problem in your code , You are missing a .reshape() function , Sharing a link to your notebook will be much helpful to point out the error.

Thank you in advance !!


Try using .reshape(-1) function in the following line

out =  self(inputs).reshape(-1)

in both training_step and validation_step and let me know it is working or not.

Not working. It still gives the same error.

/usr/local/lib/python3.6/dist-packages/ipykernel_launcher.py:23: UserWarning: Using a target size (torch.Size([24, 1])) that is different to the input size (torch.Size([24])). This will likely lead to incorrect results due to broadcasting. Please ensure they have the same size. /usr/local/lib/python3.6/dist-packages/ipykernel_launcher.py:23: UserWarning: Using a target size (torch.Size([7, 1])) that is different to the input size (torch.Size([7])). This will likely lead to incorrect results due to broadcasting. Please ensure they have the same size.

Your notebook works without a hitch on google colab. I didn’t change anything, it produces results. Do you work in your local environment?

At the end of the error messages, it is supposed to give an error name and explaination. Can you share it?

It is not an error but a user warning that a broadcasting error might occur, but still the program would run correctly.

It is not giving any error name. It only shows the output that I have pasted above.

But it is showing very large value of loss.

Depends on which loss function you’re using, whats the loss that you’re getting.

“” The target column “charges” column is included in “input_cols”, so you’re using the target to predict itself. “” Got this on my 2 Assidnment after evaluation please help me in resolving this i am not able to resolve this .
link of my notebook --> https://jovian.ai/raghavsodhi02/insurance-linear

1 Like

As the error says, you have your predicted column, among the inputs.

It’s almost as if you asked someone “What is the name of Greg?”

Look back at your notebook and adjust the input columns.

Same error and also stuck here :frowning:

As @Sebastian said you have included the column you need to predict in the input_cols, do remove the target column from the input_cols.