I have managed to start training an Alexnet model on the concatenated data, however it keeps throwing an error after its seen 320 images. The total dataset size is 6,444. I think it might be something to do with how I’ve manipulated the data to be able to concatenate it. I have flattened both inputs so they share the same dimensions, and have a batch size of 16. My model looks like this:
class MyModel(nn.Module):
        def __init__(self):
            super(MyModel, self).__init__()
            self.cnn = models.alexnet(pretrained=False)
            print(self.cnn)
            self.cnn.classifier[6] = nn.Linear(self.cnn.classifier[6].in_features, 20)
            
            self.fc1 = nn.Linear(20 + 34, 60)
            self.fc2 = nn.Linear(60, 9)
        
        def forward(self, image, pose):
            x1 = self.cnn(image)
            x1 = x1.view(batch_size,-1) #torch.Size([16,20])
            x2 = pose.view(batch_size,-1) #torch.Size([16,34])
            
            
            x = torch.cat((x1,x2), dim=1)
            x = F.relu(self.fc1(x))
            x = self.fc2(x)
            return x

but it returns this error after 20 batches in the first epoch:
RuntimeError: shape '[16, -1]' is invalid for input of size 136

Any idea on what could be causing this error?