In Pytorch Resnet class we have resnet18 architecture which uses Basic block and In that Basic block we have a sequential object called Downsample.
In Downsample pytorch is doing [1 * 1] conv2d functionality.
My question is why I am getting different output for [1 * 1]convolution in Pytorch in comparison to other framework like Darknet for the same operation.
Note - other [2 2] and [3 3] convolution are giving same output in other framework but only [1 * 1] convolution is giving very different output.
is there any different approach, which is Pytorch is using for the special case of [1 * 1]?
code
downsample = nn.Sequential(
conv1x1(self.inplanes, planes * block.expansion, stride),
norm_layer(planes * block.expansion),
)
usage
def forward(self, x):
identity = x
out = self.conv1(x)
out = self.bn1(out)
out = self.relu(out)
out = self.conv2(out)
out = self.bn2(out)
out = self.relu(out)
out = self.conv3(out)
out = self.bn3(out)
if self.downsample is not None:
identity = self.downsample(x)
out += identity
out = self.relu(out)
return out