# Second assignment of first week, DLS course 4

**URL:** <https://community.deeplearning.ai/t/second-assignment-of-first-week-dls-course-4/467116>\
**Category:** Convolutional Neural Networks\
**Tags:** coursera-platform\
**Created:** [October 10, 2023, 6:49pm UTC](https://community.deeplearning.ai/t/second-assignment-of-first-week-dls-course-4/467116 "2023-10-10T18:49:29Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Arman\_Hosse](https://avatars.discourse-cdn.com/v4/letter/a/d9b06d/32.png) [@Arman\_Hosse](https://community.deeplearning.ai/u/Arman_Hosse)\
**Post date:** [October 10, 2023, 6:49pm UTC](https://community.deeplearning.ai/t/second-assignment-of-first-week-dls-course-4/467116/1 "2023-10-10T18:49:29Z")

</div>

help! I checked my code millions of time, for the first exercise “happyModel” , I keep receiving an error in second cell after creating def happyModel(), which is :  
AttributeError Traceback (most recent call last)  
 in   
1 happy\_model = happyModel()  
2 # Print a summary for each layer  
----\> 3 for layer in summary(happy\_model):  
4 print(layer)  
5

~/work/release/W1A2/test\_utils.py in summary(model)  
34 result =   
35 for layer in model.layers:  
—\> 36 descriptors = [layer. **class**. **name** , layer.output\_shape, layer.count\_params()]  
37 if (type(layer) == Conv2D):  
38 descriptors.append(layer.padding)

/opt/conda/lib/python3.7/site-packages/tensorflow/python/keras/engine/base\_layer.py in output\_shape(self)  
2177 “”"  
2178 if not self.\_inbound\_nodes:  
 → 2179 raise AttributeError('The layer has never been called ’  
2180 ‘and thus has no defined output shape.’)  
2181 all\_output\_shapes = set(

AttributeError: The layer has never been called and thus has no defined output shape.

I think this error has nothing to do with my code and I don’t know how to fix this problem

---

<div class="post-metadata">

**Author:** ![TMosh](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/tmosh/32/9321_2.png) [@TMosh](https://community.deeplearning.ai/u/TMosh)\
**Post date:** [October 10, 2023, 7:10pm UTC](https://community.deeplearning.ai/t/second-assignment-of-first-week-dls-course-4/467116/2 "2023-10-10T19:10:53Z")

</div>

Did you include the input\_shape=(…) parameter in the ZeroPadding2D() layer?

---

<div class="post-metadata">

**Author:** ![paulinpaloalto](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/paulinpaloalto/32/187_2.png) [@paulinpaloalto](https://community.deeplearning.ai/u/paulinpaloalto)\
**Post date:** [October 10, 2023, 8:33pm UTC](https://community.deeplearning.ai/t/second-assignment-of-first-week-dls-course-4/467116/3 "2023-10-10T20:33:05Z")

</div>

> [@Arman\_Hosse](#):
>
> I think this error has nothing to do with my code and I don’t know how to fix this problem

Sorry, but I think that error has everything to do with your code. The best idea would be to spend 15 minutes studying [this thread](https://community.deeplearning.ai/t/tips-for-troubles-with-sequential-and-functional-api-syntax/52202) which gives a much nicer explanation of how the Keras Sequential and Functional APIs work than what is given to us in the notebook. Then go back and re-examine your code with that knowledge in mind and I hope that things will be a lot clearer.

---

<div class="post-metadata">

**Author:** ![paulinpaloalto](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/paulinpaloalto/32/187_2.png) [@paulinpaloalto](https://community.deeplearning.ai/u/paulinpaloalto)\
**Post date:** [October 10, 2023, 8:39pm UTC](https://community.deeplearning.ai/t/second-assignment-of-first-week-dls-course-4/467116/4 "2023-10-10T20:39:05Z")

</div>

Of course if you still have problems even after studying that thread, please ask more followup questions and we will be here to help.

---

<div class="post-metadata">

**Author:** ![Arman\_Hosse](https://avatars.discourse-cdn.com/v4/letter/a/d9b06d/32.png) [@Arman\_Hosse](https://community.deeplearning.ai/u/Arman_Hosse)\
**Post date:** [October 11, 2023, 9:49pm UTC](https://community.deeplearning.ai/t/second-assignment-of-first-week-dls-course-4/467116/5 "2023-10-11T21:49:13Z")

</div>

thank you!
