Housing Prices Code not working

Hi, I have been stuck on this code for quite some time. I am getting the epoch values and everything but this one syntax error keeps coming up and I am not so sure how to fix it. I have been able to complete the other labs successfully but not this one. Any guidance on this will be much appreciated.


(staff edit: removed code)

Hi @Shantala_Totada

Welcome to the community.

The error tells you, you are trying to use the predict method on the model variable, but model is a string instead of a tensorflow/keras model which does not have this method. You therefore need to use load_model and pass it the location of the model file, which should return you a tensorflow model using which you can then use predict.

Mistakes in your code.

  1. You do not require to import tf, keras nd numpy again in the grader cell as at the beginning only it is imported, rather for the model write the code with inclusive of keras and models.

  2. Your xs and ys variables are incorrect. There are only 6 bedrooms but your xs mentions 10 variable and then the correlation to ys is again incorrect as ys increases to the xs by 50,000 by pricing. So if your xs is 1, 2, 3, then ys would be 1, 1.5, 2

  3. You also have either completely edited the grader cell as I can see your codes arrangement are incorrect. The formatted grader cell doesn’t look like the one you shared

Kindly get a fresh copy and re do the assignment to prevent failure of grade.

  1. You also have edited the return statement from model to mode.predict.

Kindly note these assignments only require you to write codes between ##START AND END CODE HERE####. EDITING OR WRTING ANY CODES OUTSIDE THIS ### EVEN IN GRADING CELL CAUSE FAILURE OF GRADES.

  1. Yours statement for defining model for input is incorrect. Search for that answer by using search tool, you will find many posts on how to write that code correct. You mentioned only keras. Sequential and keras layers dense that is incorrect.

I am sharing how the grader cell looks so you can compare


1 Like

Thank you for your help @Deepti_Prasad

Maybe i saw this issue in a wrong way.


Hi Elirod,

You were not completely incorrect, just that error first showed the major error of being model.predict, so it is first showing attribute error. Once the learner will do that correction, it will show the other error I mentioned. As I remembered what all mistakes in that grader cell I could see I mentioned, so the learner can look at all the mistakes and do the corrections necessarily.

Also the most important part, learner has posted codes from grader cell which is completely against community guidelines, so kindly remove the codes from your post @Shantala_Totada shantala


1 Like