My input images are (210,128,128,3) size.
Giving errors–RuntimeError: Given groups=1, weight[32, 3, 5, 5], so expected input[210, 128, 128, 3] to have 3 channels, but got 128 channels instead
(TRIED OTHER answers but nothing works)
def init(self):
super(Net, self).init()
self.conv1 = nn.Conv2d(3, 32, 5, padding=4)
self.conv2 = nn.Conv2d(32, 96, 5)
# max pooling layer
self.pool = nn.MaxPool2d(2, 2)
self.fc1 = nn.Linear(29*29*96, 500)
# linear layer (500 -> 10)
self.fc2 = nn.Linear(500, 10)
# dropout layer (p=0.25)
self.dropout = nn.Dropout(0.25)
def forward(self, x):
# add sequence of convolutional and max pooling layers
x = self.pool(F.relu(self.conv1(x)))
x = self.pool(F.relu(self.conv2(x)))
# flatten image input
x = x.view(-1, 29*29*96)
# add dropout layer
x = self.dropout(x)
# add 1st hidden layer, with relu activation function
x = F.relu(self.fc1(x))
# add dropout layer
x = self.dropout(x)
# add 2nd hidden layer, with relu activation function
x = (self.fc2(x))
return x
create a complete CNN
model = Net()