Hi,
I am trying to run a basic CNN for binary classification of medical images. I am getting this error:
x = x.view(-1, 16 * 53 * 53)
RuntimeError: shape ‘[-1, 44944]’ is invalid for input of size 1628160
CNN:
class Net(nn.Module):
def init(self):
super(Net, self).init()
self.conv1 = nn.Conv2d(3, 6, 5)
self.pool = nn.MaxPool2d(2, 2)
self.conv2 = nn.Conv2d(6, 16, 5)
self.fc1 = nn.Linear(16 * 53 * 53, 120)
self.fc2 = nn.Linear(120, 84)
self.fc3 = nn.Linear(84, 2)
def forward(self, x):
x = self.pool(F.relu(self.conv1(x)))
x = self.pool(F.relu(self.conv2(x)))
x = x.view(-1, 16 * 53 * 53)
x = F.relu(self.fc1(x))
x = F.relu(self.fc2(x))
x = self.fc3(x)
return x
Images - 3x224X224
Batch Size - 32
Though it works with x = x.view(-1, 16 * 53 * 60). But I don’t understand it why it wouldn’t work with 53*53.
I am new to Pytorch and if anyone can help me out I really appreciate it…