I have another question
I am trying to train Resnet50 and Inception_v3 simultaneously
I make the following class
class TwoInputsNet(nn.Module):
def __init__(self):
super(TwoInputsNet, self).__init__()
self.model1 = torchvision.models.resnet50(pretrained=True)
self.model1.fc = nn.Linear(2048, 1024)
self.model2 = torchvision.models.inception_v3(pretrained=True)
self.model2.fc = nn.Linear(2048, 1024)
self.fc2 = nn.Linear(2048, 1)
def forward(self, input1, input2):
c = self.model1(input1)
f = self.model2(input2)
combined = torch.cat((c,torch.Tensor(f)), dim=1)
out = self.fc2(combined)
return out
and I am getting the following error:
File "D:/Face Beauty Pytorch/transfer_learning_inception_resnet50_regression.py", line 152, in <module>
preds = model(images1, images2)
File "c:\users\fares\appdata\local\programs\python\python37\lib\site-packages\torch\nn\modules\module.py", line 541, in __call__
result = self.forward(*input, **kwargs)
File "D:/Face Beauty Pytorch/transfer_learning_inception_resnet50_regression.py", line 82, in forward
f = self.model2(input2)
File "c:\users\fares\appdata\local\programs\python\python37\lib\site-packages\torch\nn\modules\module.py", line 541, in __call__
result = self.forward(*input, **kwargs)
File "c:\users\fares\appdata\local\programs\python\python37\lib\site-packages\torchvision\models\inception.py", line 132, in forward
aux = self.AuxLogits(x)
File "c:\users\fares\appdata\local\programs\python\python37\lib\site-packages\torch\nn\modules\module.py", line 541, in __call__
result = self.forward(*input, **kwargs)
File "c:\users\fares\appdata\local\programs\python\python37\lib\site-packages\torchvision\models\inception.py", line 332, in forward
x = self.conv1(x)
File "c:\users\fares\appdata\local\programs\python\python37\lib\site-packages\torch\nn\modules\module.py", line 541, in __call__
result = self.forward(*input, **kwargs)
File "c:\users\fares\appdata\local\programs\python\python37\lib\site-packages\torchvision\models\inception.py", line 353, in forward
x = self.bn(x)
File "c:\users\fares\appdata\local\programs\python\python37\lib\site-packages\torch\nn\modules\module.py", line 541, in __call__
result = self.forward(*input, **kwargs)
File "c:\users\fares\appdata\local\programs\python\python37\lib\site-packages\torch\nn\modules\batchnorm.py", line 81, in forward
exponential_average_factor, self.eps)
File "c:\users\fares\appdata\local\programs\python\python37\lib\site-packages\torch\nn\functional.py", line 1666, in batch_norm
raise ValueError('Expected more than 1 value per channel when training, got input size {}'.format(size))
ValueError: Expected more than 1 value per channel when training, got input size torch.Size([1, 768, 1, 1])
Could you suggest any solution to this issue ??