# C1\_W3 - Convolution

**URL:** <https://community.deeplearning.ai/t/c1-w3-convolution/402220>\
**Category:** TensorFlow: Data and Deployment Resources\
**Created:** [July 30, 2023, 1:44pm UTC](https://community.deeplearning.ai/t/c1-w3-convolution/402220 "2023-07-30T13:44:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Raphael\_Garcia\_Morei](https://avatars.discourse-cdn.com/v4/letter/r/f475e1/32.png) [@Raphael\_Garcia\_Morei](https://community.deeplearning.ai/u/Raphael_Garcia_Morei)\
**Post date:** [July 30, 2023, 1:44pm UTC](https://community.deeplearning.ai/t/c1-w3-convolution/402220/1 "2023-07-30T13:44:24Z")

</div>

Hello!  
I have a question, could you help me?  
Considering the code below:  
"  
model = tf.keras.models.Sequential([  
tf.keras.layers.Conv2D(32, (3,3), activation=‘relu’, input\_shape=(28,28,1)),  
tf.keras.layers.MaxPooling2D(2,2),

```
     tf.keras.layers.Flatten(),
     tf.keras.layers.Dense(128, activation='relu'),
     tf.keras.layers.Dense(10, activation='softmax')
 ])

```

"

- I can say that the command “tf.keras.layers.Conv2D(32, (3,3), activation=‘relu’, input\_shape=(28,28,1)),” creates 32 feature matrices and then reduces each one in half with the command “tf.keras.layers.MaxPooling2D(2,2),”?

Best regards

---

<div class="post-metadata">

**Author:** ![conscell](https://avatars.discourse-cdn.com/v4/letter/c/dec6dc/32.png) [@conscell](https://community.deeplearning.ai/u/conscell)\
**Post date:** [July 22, 2024, 2:38am UTC](https://community.deeplearning.ai/t/c1-w3-convolution/402220/2 "2024-07-22T02:38:47Z")

</div>

Yes, you can say that the command `tf.keras.layers.Conv2D(32, (3,3), activation='relu', input_shape=(28,28,1))` creates 32 feature maps (or matrices). Each feature map is generated by applying 32 different filters, each of size 3x3, across the input image.

Following this, the command `tf.keras.layers.MaxPooling2D(2,2)` performs max pooling on these 32 feature maps. Max pooling with a pool size of 2x2 and a stride of 2 (defaults to `pool_size`) reduces the spatial dimensions of each feature map by half. This means that if the feature maps were of size (26, 26) before max pooling (since a 3x3 filter with ‘valid’ padding reduces the size from 28x28 to 26x26), they will be of size (13, 13) after max pooling.
