Hi,
I am pretty new to pytorch and neural networks. So far have only worked with pretrained model in pytorch. I want to implement a cusstom model to my already existing pipeline. I have found deeplabv3 plus implementation and trying to modify it for my pipeline. I have following implementation and I am getting this error.
class DeepLabHeadV3Plus(nn.Module):
def __init__(self, in_channels, low_level_channels, num_classes, aspp_dilate=[12, 24, 36]):
super(DeepLabHeadV3Plus, self).__init__()
self.project = nn.Sequential(
nn.Conv2d(low_level_channels, 48, 1, bias=False),
nn.BatchNorm2d(48),
nn.ReLU(inplace=True),
)
self.aspp = ASPP(in_channels, aspp_dilate)
self.classifier = nn.Sequential(
nn.Conv2d(304, 256, 3, padding=1, bias=False),
nn.BatchNorm2d(256),
nn.ReLU(inplace=True),
nn.Conv2d(256, num_classes, 1)
)
def forward(self, feature):
low_level_feature = self.project( feature['low_level'] )
output_feature = self.aspp(feature['out'])
output_feature = F.interpolate(output_feature, size=low_level_feature.shape[2:], mode='bilinear', align_corners=False)
return self.classifier( torch.cat( [ low_level_feature, output_feature ], dim=1 ) )
My error is:
low_level_feature = self.project( feature[‘low_level’] )
IndexError: too many indices for tensor of dimension 4
I get it that I have tensor of size 04 but I am trying to dimension it an extra. but how can I get rid of it. My dataloader has shape of tensor (B,C,H,W) = (32, 3, 320, 320). Any suggestion or help would be a lot of help.