I wanted to try out changing the resnet code in pytorch and experimenting a bit with it… So I was going to try using different types of kernels in the convolution layer. For now I’m only trying it with dilated and normal kernels.
Original code in resnet in pytorch.vision for making a conv2d layer:
def conv3x3(in_planes, out_planes, stride=1, groups=1, dilation=1):
"""3x3 convolution with padding"""
return nn.Conv2d(in_planes, out_planes, kernel_size=3, stride=stride,
padding=dilation, groups=groups, bias=False, dilation=dilation)
I want to do something like this
def conv3x3(in_planes, out_planes, stride=1, groups=1, dilation=1):
"""3x3 convolution with padding"""
l1 = nn.Conv2d(in_planes, out_planes//2, kernel_size=3, stride=stride,
padding=dilation, groups=groups, bias=False, dilation=dilation)
l2 = nn.Conv2d(in_planes, out_planes - out_planes//2, kernel_size=3, stride=stride,
padding=dilation, groups=groups, bias=False, dilation=dilation+1)
l3 = torch.stack([l1, l2], dim=0)
print(l3)
return l3
But torch.stack
expects 2 tensors and therefore wont be able to merge the two convolution layers. So is there any way I can merge them? I dont want to change the interface resnet uses, that is not change any other part of the resnet code.
Thanks a lot