This error will not occur at the same point always.
class DeepVANet(nn.Module):
def __init__(self, bio_input_size=32, face_feature_size=16, bio_feature_size=64,pretrain=True):
super(DeepVANet,self).__init__()
self.face_feature_extractor = FaceFeatureExtractor(feature_size=face_feature_size,pretrain=pretrain)
self.bio_feature_extractor = Transformer1d(
bio_input_size,
n_classes=64,
n_length=128,
d_model=32,
nhead=8,
dim_feedforward=128,
dropout=0.1,
activation='relu'
)
self.classifier = nn.Sequential(
nn.Linear(face_feature_size + bio_feature_size, 50),
nn.ReLU(inplace=True),
nn.Linear(50, 20),
nn.ReLU(inplace= True),
nn.Linear(20,1),
nn.Sigmoid()
)
def forward(self,x):
img_features = self.face_feature_extractor(x[0])
bio_features = self.bio_feature_extractor(x[1])
features = torch.cat([img_features,bio_features.float()],dim=1)
output = self.classifier(features)
output = output.squeeze(-1)
return output
BioFeatureExtractor(passed through CNN and then through LSTM, to give me 16 features) and bio_feature_extractor(gives me 64 features) are two different models, I am trying to fuse them to classify either 0 or 1.
I have run them both separately, they work perfectly fine, this problem only arises, when I am trying to fuse both the models.
The model can be found at GitHub - vvikasreddy/Deepvaner
let me know, if you need more info…