Hello all,
I’m trying to run this model:
class CNN(nn.Module):
def __init__(self):
super(CNN, self).__init__()
self.conv1 = nn.Conv2d(3, 5, 3, stride = 2)
self.conv2 = nn.Conv2d(5, 3, 3, stride = 1)
self.pool1 = nn.MaxPool2d(2,2)
self.conv3 = nn.Conv2d(3,3, 3, stride = 1)
self.conv4 = nn.Conv2d(3,3,3, stride=1)
self.pool2 = nn.MaxPool2d(2,2)
self.batch = nn.BatchNorm2d(10)
self.fc1 = nn.Linear(810, 50)
self.fc2 = nn.Linear(50, 7)
self.local = nn.Sequential(
nn.Conv2d(3, 8, kernel_size = 7),
nn.MaxPool2d(2, stride = 2),
nn.ReLU(True),
nn.Conv2d(8, 10, kernel_size = 5),
nn.MaxPool2d(2, stride = 2),
nn.ReLU(True)
)
self.fc_local = nn.Sequential(
nn.Linear(640, 32),
nn.ReLU(True),
nn.Linear(32, 3 * 2)
)
self.fc_local[2].weight.data.zero_()
self.fc_local[2].bias.data.copy_(torch.tensor([1, 0, 0, 0, 1, 0], dtype = torch.float))
def stn(self, x):
xs = self.local(x)
xs = xs.view(-1, 640)
y = self.fc_local(xs)
y = y.view(-1, 2, 3)
def forward(self, input):
x = self.stn(input)
x = F.relu(self.conv1(x))
x = self.conv2(x)
x = F.relu(self.pool1(x))
x = F.relu(self.conv3(x))
x = self.batch(self.conv4(x))
x = F.relu(self.pool2(x))
x = F.dropout(x)
x = x.view(-1, 810)
x = F.relu(self.fc1(x))
x = self.fc2(x)
return x
and when I try to feed it image data it returns:
TypeError: conv2d(): argument 'input' (position 1) must be Tensor, not NoneType
I know my DataLoader is set up properly because I am able to plot the images fine and it worked with a previous model.
Does anybody have any ideas? Thanks in advance!