Starter notebook: https://jovian.ai/aakashns/02-insurance-linear-regression
In this assignment, we’re going to use information like a person’s age, sex, BMI, no. of children, and smoking habit to predict the price of yearly medical bills. We will train a model with the following steps:
- Download and explore the dataset
- Prepare the dataset for training
- Create a linear regression model
- Train the model to fit the data
- Make predictions using the trained model
Steps to complete the assignment
- Fork & run this notebook: https://jovian.ai/aakashns/02-insurance-linear-regression
- Fill out all the ??? in the notebook to complete the assignment, and commit the final version to Jovian
- (Optional) Replicate the model training for another dataset & write a blog post
- (Optional) Share your work with the community on the https://jovian.ai/forum/t/share-your-work-here-assignment-2/4931 thread
Make sure to review the material from Lecture 2 before starting the assignment. Please reply here if you have any questions or face issues. The recommended platform for writing your blog post is medium.com .
I’m getting this error while trying to fit my model: RuntimeError: element 0 of tensors does not require grad and does not have a grad_fn. I have been trying to find what produces the error, but I could not find it. This is the link to the project: link
Thanks in advance
@lsalvador-ht As I can see in your notebook , there is some wrong codes in your Model cells.
In the training_step and validation_step function the loss = F.mse_loss line should have
out variable instead of
inputs variable in its arguements.
Hope it helps, Thank You.
My val_loss and all the weights and bias parameters in the model became nan when I call fit method.
And I do not know why.
It would be really nice if someone can have a look or give me some advices.
Thank you in advance
Here is my notebook
I would try and restart the notebook. Perhaps you’ve picked too large learning rate first, and you experienced a thing called “exploding gradients”.
I would also suggest to incorporate a method called “gradient clipping” in your training (
Hi, In the second assignment (02-insurance-linear) I am getting an error for the command.
Has anyone faced this error yet.
@hargurjeet you have to put it in quotation mark ‘something’
Please explain why it is giving me NAN values in val_loss and even when I am running evaluate(model,val_loader) second time it is resulting as NAN .
Your learning rate is too big
Ok, then what learning rate should I keep instead?
Depends on the model and on you, if its giving nan with 1e-2 make it 1e-4 then train 5 to 10 epochs then decrease the LR to 1e-5 then again train 10 epochs it depends completely on you and the model.
ok I will try it Thank You
your_name is a string variable, insert “hargurjeet”
I am getting this error someone please help:
RuntimeError: The size of tensor a (7) must match the size of tensor b (127) at non-singleton dimension 1
Hello guys, Here is my first Model in this course, check this link
i am getting a very large val_loss using mse_loss, is it with everyone or just me. should i change my loss function?
@siddhantramteke369 could you share the notebook please.
This problem of your is solved just do .type(torch.float32) while making tensors and it shall work fine, but it seems there are other problems in your noteobok.
I am getting the below error, Can anyone suggest on the resolution
link to my notebook - https://jovian.ai/hargurjeet/02-insurance-linear-regression