AttributeError: 'NoneType' object has no attribute 'compile'

Can anyone help me to fix this error?

You have to possibly share more of the error so people here can have more insight into it. What this error says is that the compile method of your model is not working because the model itself is of NoneType, the model should be a type - tf.keras.Model - callable object. I would suggest to go through the notebook again it might be you are forgetting to run a cell above the cell where compile happens.

But this was filed under NLP Course 1 Week 1, which is the Logistic Regression assignment there. It only involves numpy and pandas, no TF in sight. But maybe the grader uses TF? Or maybe this thread was just filed under the wrong category?

Generally speaking, when you get an error about something being NoneType, it means you missed some piece of code that you were supposed to fill in. It would be worth just doing “Kernel → Restart and Clear Output” and then “Cell → Run All” in the notebook. Then carefully scroll through everything and check that no errors are being thrown by any of the cells.

Dear @paulinpaloalto and @gent.spah,

Thanks! It works now.

1 Like