# Residual Networks (ResNet)

**URL:** <https://d2l.discourse.group/t/residual-networks-resnet/333>\
**Category:** tensorflow\
**Created:** [June 29, 2020, 9:33pm UTC](https://d2l.discourse.group/t/residual-networks-resnet/333 "2020-06-29T21:33:46Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![astonzhang](https://yyz2.discourse-cdn.com/free1/user_avatar/d2l.discourse.group/astonzhang/32/52_2.png) [@astonzhang](https://d2l.discourse.group/u/astonzhang)\
**Post date:** [June 29, 2020, 9:33pm UTC](https://d2l.discourse.group/t/residual-networks-resnet/333/1 "2020-06-29T21:33:46Z")

</div>

[https://d2l.ai/chapter\_convolutional-modern/resnet.html](https://d2l.ai/chapter_convolutional-modern/resnet.html)

---

<div class="post-metadata">

**Author:** ![Ehsan](https://avatars.discourse-cdn.com/v4/letter/e/96bed5/32.png) [@Ehsan](https://d2l.discourse.group/u/Ehsan)\
**Post date:** [May 9, 2021, 8:51pm UTC](https://d2l.discourse.group/t/residual-networks-resnet/333/2 "2021-05-09T20:51:30Z")

</div>

according to [https://arxiv.org/pdf/1512.03385.pdf](https://arxiv.org/pdf/1512.03385.pdf) i think there is a 1000-d fully connected softmax layer missing at in the last part of the model

---

<div class="post-metadata">

**Author:** ![Enrique98](https://avatars.discourse-cdn.com/v4/letter/e/f475e1/32.png) [@Enrique98](https://d2l.discourse.group/u/Enrique98)\
**Post date:** [August 25, 2021, 12:39am UTC](https://d2l.discourse.group/t/residual-networks-resnet/333/4 "2021-08-25T00:39:38Z")

</div>

Hi Ehsan. Maybe I’m correct about this, so take it with a grain of salt. The ResNet architecture was trained with the ImageNet 2012 classification dataset, this dataset includes 1000 different classes, so that is way the last Fully connected layer they used is a 1000-FC. In the case of the book, we are using a 10 classes dataset for faster learning times, that’s why we use a 10-FC layer instead. Hope this helps !!!

In relation of the softmax function, I don’t know why this was skipped.

---

<div class="post-metadata">

**Author:** ![thainq](https://yyz2.discourse-cdn.com/free1/user_avatar/d2l.discourse.group/thainq/32/3536_2.png) [@thainq](https://d2l.discourse.group/u/thainq)\
**Post date:** [February 13, 2022, 11:38am UTC](https://d2l.discourse.group/t/residual-networks-resnet/333/5 "2022-02-13T11:38:50Z")

</div>

I the last layer the resnet use GlobalAveragePooling2D instead of Dense layer? anyone know the reason why do we use GlobalAveragePooling2D is getting better?

---

<div class="post-metadata">

**Author:** ![sanjaradylov](https://yyz2.discourse-cdn.com/free1/user_avatar/d2l.discourse.group/sanjaradylov/32/1419_2.png) [@sanjaradylov](https://d2l.discourse.group/u/sanjaradylov)\
**Post date:** [February 13, 2022, 4:17pm UTC](https://d2l.discourse.group/t/residual-networks-resnet/333/6 "2022-02-13T16:17:50Z")

</div>

@thainq ResNet actually has one dense layer after pooling to compute logits, btw.  
`GlobalAveragePooling2D` aggregates all the computed hidden representations prior to `Dense`. You can replace it with another `Dense` layer but this will flatten all the representations without aggregating them across channels. As a result, you have even more parameters to train. Give this a try and compare your results with the original implementation.

---

<div class="post-metadata">

**Author:** ![thainq](https://yyz2.discourse-cdn.com/free1/user_avatar/d2l.discourse.group/thainq/32/3536_2.png) [@thainq](https://d2l.discourse.group/u/thainq)\
**Post date:** [February 14, 2022, 12:40am UTC](https://d2l.discourse.group/t/residual-networks-resnet/333/7 "2022-02-14T00:40:59Z")

</div>

that mean the GlobalAveragePooling2D is able to retain the spatial information of input better than Den layer?
