Code working perfectly on colab but shows parsing error while submitting


i have been stuck with the for the past 4 hr. now , don’t know what’s wrong the code give result in google Colab but wont pass on the grader.
Please Rely fast i am on a tight schedule.

Hi @Durgance_Gaur,
can you send your code?

1 Like

C2_W4_Assignment_(2) (9).ipynb (47.9 KB)

I think you should take a look at the units in the last Dense layer. 25 doesn’t make sense, to me.

1 Like

Thank for the remark i was just testing around 25,24,26. will check that part but still can u please help me, i dont understand what is this line 14 this program keeps talking about

I suggest you to first change this units in the last layer accordingly and then check if you get other errors, and in that case send me a screenshot of the error.

1 Like



i used unique label from training data as the input of the last layer but the output in the grader is still the same

  1. fit_generator is deprecated, use fit
  2. write the number (suggestion, not 25)

Screenshot 2021-11-07 at 13.31.52

1 Like

i have now used [26,27,28] as the number and changed it to fit


C2_W4_Assignment_(2) (15).ipynb (33.9 KB)
but still its keeps giving me parsing error…
why is it saying invalid syntax even though it works on my colab.
I really appreciate you helping me.
Thank you

Don’t worry, piece by piece we’ll fix it. Next, your model is trained for 2 epochs with a micro learning rate, so basically it doesn’t learn anything: change
optimizer=‘adam’ (with default learning rate)
and try with more epochs, like 5, or more

Probably your error is something different, but right now, your model doesn’t reach the accuracy requested.

1 Like


This time is used 15 epochs and changed the optimizer to the default.
but my evaluation accuracy is much higher than the asked one what should i do

Sorry @Durgance_Gaur ,
it appears that the Coursera labs are still wanting fit_generator (that as I told you is currently deprecated). So please, put back fit_generator.

Hope it helps

1 Like

but i dont understand what is this parsing syntax error it keeps popping up pls help

I tried submitting your code with the modifications we discussed about and I actually passed it. It seems you have a syntax error, but you told me you execute every cell with no mistake, and the shapes are as requested. Can you try using the Coursera platform, instead than Google Colab?

1 Like

Thank you ! i don’t why this happened i just pasted my code in the coursera platform it was passed in the first time . This google colab issue took my whole day.
This was very irritating but thank you for helping me…:blush::blush:

Great. Sometimes these things just happen. Glad to be of any help. Happy learning.

1 Like