# Week1 assignment\_2 convolutional\_model

**URL:** <https://community.deeplearning.ai/t/week1-assignment-2-convolutional-model/23443>\
**Category:** Convolutional Neural Networks\
**Tags:** coursera-platform\
**Created:** [July 26, 2021, 1:17pm UTC](https://community.deeplearning.ai/t/week1-assignment-2-convolutional-model/23443 "2021-07-26T13:17:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Afsar\_Khan](https://avatars.discourse-cdn.com/v4/letter/a/f14d63/32.png) [@Afsar\_Khan](https://community.deeplearning.ai/u/Afsar_Khan)\
**Post date:** [July 26, 2021, 1:17pm UTC](https://community.deeplearning.ai/t/week1-assignment-2-convolutional-model/23443/1 "2021-07-26T13:17:25Z")

</div>

In convolutional model encountering the following error  
input\_img = tf.keras.Input(shape=input\_shape)  
## CONV2D: 8 filters 4x4, stride of 1, padding ‘SAME’  
Z1 = tf.keras.layers.Conv2D(filters = 8, strides=(1), kernel\_size = [4, 4], padding = ‘same’)(input\_img)  
## RELU  
A1 = tf.keras.layers.ReLU()(Z1)  
## MAXPOOL: window 8x8, stride 8, padding ‘SAME’  
P1 = tf.keras.layers.MaxPooling2D(pool\_size=(8, 8), strides=(8, 8), padding=‘same’)(A1)  
## CONV2D: 16 filters 2x2, stride 1, padding ‘SAME’  
Z2 = tf.keras.layers.Conv2D(filters = 16, strides = (1), kernel\_size = [2, 2], padding = ‘same’)(input\_img)  
## RELU  
A2 = tf.keras.layers.ReLU()(Z2)  
## MAXPOOL: window 4x4, stride 4, padding ‘SAME’  
P2 = tf.keras.layers.MaxPooling2D(pool\_size=(4, 4), strides=(4, 4), padding=‘same’)(A2)  
## FLATTEN  
F = tf.keras.layers.Flatten()(input\_img)  
## Dense layer  
## 6 neurons in output layer. Hint: one of the arguments should be “activation=‘softmax’”  
outputs = tf.keras.layers.Dense(units=6, activation=‘softmax’)(F)  
# YOUR CODE STARTS HERE

Model: “functional\_15”

* * *

# Layer (type) Output Shape Param #

input\_9 (InputLayer) [(None, 64, 64, 3)] 0

* * *

flatten\_8 (Flatten) (None, 12288) 0

* * *

# dense\_8 (Dense) (None, 6) 73734

Total params: 73,734  
Trainable params: 73,734  
Non-trainable params: 0

* * *

Test failed  
Expected value

[‘Conv2D’, (None, 64, 64, 8), 392, ‘same’, ‘linear’, ‘GlorotUniform’]

does not match the input value:

## [‘Flatten’, (None, 12288), 0]

AssertionError Traceback (most recent call last)  
 in   
15 [‘Dense’, (None, 6), 390, ‘softmax’]]  
16  
—\> 17 comparator(summary(conv\_model), output)

~/work/release/W1A2/test\_utils.py in comparator(learner, instructor)  
20 “\n\n does not match the input value: \n\n”,  
21 colored(f"{a}", “red”))  
—\> 22 raise AssertionError(“Error in test”)  
23 print(colored(“All tests passed!”, “green”))  
24

AssertionError: Error in test

---

<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:** [July 26, 2021, 7:39pm UTC](https://community.deeplearning.ai/t/week1-assignment-2-convolutional-model/23443/2 "2021-07-26T19:39:54Z")

</div>

In the Z2 and F layers, you’re passing the wrong data argument.

---

<div class="post-metadata">

**Author:** ![Afsar\_Khan](https://avatars.discourse-cdn.com/v4/letter/a/f14d63/32.png) [@Afsar\_Khan](https://community.deeplearning.ai/u/Afsar_Khan)\
**Post date:** [July 27, 2021, 9:45am UTC](https://community.deeplearning.ai/t/week1-assignment-2-convolutional-model/23443/3 "2021-07-27T09:45:09Z")

</div>

Ok, thanks, it helps a lot.
