TypeError: cannot pickle 'module' object when calling model.save()

In the Assignment of the week 3 the last code cell, which is supposed to save model, isn’t working.

Here’s the code:

# Save your model in the SavedModel format

# Compress the directory using tar
! tar -czvf saved_model.tar.gz saved_model/

And I get the error:

TypeError                                 Traceback (most recent call last)
<ipython-input-17-27516a25b445> in <module>
      1 # Save your model in the SavedModel format
----> 2 model.save('saved_model/my_model')
      4 # Compress the directory using tar
      5 get_ipython().system(' tar -czvf saved_model.tar.gz saved_model/')


TypeError: cannot pickle 'module' object

Please, help!


Did you go back and checked if any error in model?

If not able to find, please send your notebook assignment via personal DM. Click on my name and then message.

I will get back to you in a while


I don’t think there is an error. The model is working, it achieved MAE 3.19 on the validation set. I sent the notebook to your DM.

Thanks for the help, appreciate it!


try to use loss=‘mse’ rather than Huber loss

and learning rate of 1e-6 for optimizer as used in lr_schedule

It worked! :white_check_mark:
Thank you so much for the help! I was desperate and didn’t know what to do. Thank you!