Week1 Assignment 2, Exercise 1 - happyModel

Just want to report potentially a missing line of code in the Assignment 2, Exercise 1 - happyModel workbook, which was necessary for me, in order to pass this Exercise.

After I complete the code for the happyModel function, the next assessment step will fail with an error:
AttributeError: The layer has never been called and thus has no defined output shape.

Based on the error message, I added a new line after the “YOUR CODE ENDS HERE” line, outside of the model block, which calls the build() method before the return statement. This fixed the above error.

Please kindly review if the workbook needs to updated to avoid this error. Thanks

You do not need to add any code to use the build() method.
There is some other error in your code that you’re compensating for.

Cell 4 has the happyModel() definition.
Cell 5 tests that your sequential model is correct.
Cell 6 compiles it.

Thanks very much for your comments.
I reviewed the assignment instruction and my code, I think I figured out what’s wrong. I didn’t set the input_shape for the first ZeroPadding2D layer. Fixing that solved the error.

Thanks for your report.

How do I set the input shape for the zeroPadding layer? I only see online examples for the Conv2D layer!!! I’m getting the same layer error! Please help

Edit: just got this thing to work. Solving this happyModel requires a lot of trial and error. I wish there wereCNN examples in the videos. Struggling to learn how to program in tensorflow, is not as important as struggling to program CNNs from scratch.

Students struggling to learn to program in tensorflow is equivalent to giving a commercial pilot a foreign fighter jet simulation and telling him to "figure out the buttons for yourself buddy " . Like we already understand how to fly a plane , but we’re busy trying to learn another language instead of learning how to fly a different style of jet, this isn’t a course in tensorflow programming.


you might be missing input_shape. Add input_shape = (64,64,3) as argument in ZeroPadding2D.
input_shape argument is not specified in the ‘ZeroPadding2D’ documentation, which makes it really confusing. Hope it save lot of time for others who are stuck here.