ResNetv2 snippet

The ResNetv2 is a neural network architecture used for image classification, regression and feature extraction. It uses skip connections to add the input of a group of convolutions to its output.

The idea is to build a network consisting of branches with skip connections. For each branch, you then learn the difference, the residual activation-map, between the input and the output of the branch. This residual activation-map is added together with the previous activation-maps building the “collective knowledge” of the ResNet.

Deeper neural networks have historically been hard to train. Residual learning with skip connections made it possible to successfully train deeper models than ever before, there are well-performing networks with over 1000 layers. For most recent models we now observe that deeper models are more powerful.

ResNet branch with skip connection
Figure 1. ResNet branch with skip connection

ResNetv2 architecture

There are many variations of the ResNetv2 architecture. We define the ResNetv2 architecture as follows:

ResNet small and large

We’ve implemented two versions of ResNetv2 on the platform, one Small for images close to 32x32 pixels and one Large for images 224x224 pixels and larger.

Group of blocks

The ResNetv2 model is large. To make life easier for you; we’ve grouped parts of the model into two functional groups of blocks, the Residual group - identity and the Residual group - projection. This makes the presentation of architectures much more understandable.

As stated above, for each group, the model learns the residual activation-map between the input and the output of the branch. This residual is added together with the previous activation-maps building the “collective knowledge” of the ResNet.

ResNetv2 groups PA5
Note
Do not edit the groups of blocks.

Residual group - projection

The Residual group - projection is used to shrink the activation-map and increase the number of filters. The reason to shrink is to combine information from a larger part of the original activation-map. This condenses the learned information.

The group consists of:

  • A 1x1 2D convolution with stride 2. This is what makes the activation-map shrink.

  • Residual branch - projection. The branch includes three convolutions, where the last two are preceded by batch normalization and an activation. The first convolution has a stride of 2 to shrink the activation-map.

Residual group - identity

When using the Residual group - identity the input and output will have the same dimensions. The model learns the residual activation-map between the input and the output of the branch.

The group consists of:

  • Residual branch - identity. The branch includes three convolutions, each preceded by a batch normalization and an activation.

  • A skip connection.

How to use the ResNet snippet

Note
Do not edit the groups of blocks.

To add a ResNet snippet open the Snippet section in the Inspector and click on one of the ResNet snippets.

When using the ResNet snippet you could consider the following things:

  • In the Input block, we recommend that you use image augmentation.

  • Change the number of units in the last Dense block to match the number of classes you have. Also, change the activation.

  • Set the correct Loss function in the Target block and specifying the correct loss.

  • For optimizer we recommend you to use ADAM with learning rate 0.001 or SGD with momentum and learning rate 0.01.

References

Kaiming He, Xiangyu Zhang, Shaoqing Ren, Jian Sun: Identity Mappings in Deep Residual Networks, 2016.

Kaiming He, Xiangyu Zhang, Shaoqing Ren, Jian Sun: Deep Residual Learning for Image Recognition, 2015.

Get started for free