Skip to content
Advertisement

How downsample work in ResNet in pytorch code?

In this pytorch ResNet code example they define downsample as variable in line 44. and line 58 use it as function. How this downsample work here as CNN point of view and as python Code point of view.

code example : pytorch ResNet

i searched for if downsample is any pytorch inbuilt function. but it is not.

JavaScript

Advertisement

Answer

In this ResNet example, Here when we define BasicBlock class we pass downsample as constructor parameter.

JavaScript

if we pass nothing to class then downsample = None , as result identity will not changed.

When we pass downsample = "some convolution layer" as class constructor argument, It will downsample the identity via passed convolution layer to sucessfully perform addition. this layer will downsample the identity through code as mentioned

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement