I need to modify the following model by adding one linear layer followed by one dropout layer and finally one linear layer(by concatenating one output from dropout layer and one from tabular data of 12 columns of data) to give one regression value as output.
Model class link:–> External-Attention-pytorch/CoAtNet.py at master · xmu-xiaoma666/External-Attention-pytorch · GitHub 1
I tried this:
class coAtNet_Model(nn.Module):
    def __init__(self):
        super(coAtNet_Model, self).__init__()
        self.model = CoAtNet(3,224)
        self.classifier = nn.Linear(14, 128)
        self.dropout = nn.Dropout(0.1)
        self.out = nn.Linear(128 + 12, 1)
        
    def forward(self, image, tabular_data_inputs):
        x = self.model(image)
        x = self.classifier(x)
        x = self.dropout(x)
        x = torch.cat([x, tabular_data_inputs], dim=1)
        x = self.out(x)
        
        return x

model = coAtNet_Model()
but getting error as: —>
x = torch.cat([x, tabular_data_inputs], dim=1)
x = self.out(x)
RuntimeError: Tensors must have same number of dimensions: got 2 and 4
please help me in this.