I am new to neural networks and currently trying to build a CNN with 2 conv layers.
class CNN(nn.Module):
def __init__(self):
super(CNN, self).__init__()
self.conv1 = nn.Conv2d(in_channels = 1, out_channels = 16, kernel_size = 3, stride = 1, padding = 1),
self.maxp1 = nn.MaxPool2d(2),
self.conv2 = nn.Conv2d(in_channels = 16, out_channels = 16, kernel_size = 3, stride = 1, padding = 1),
self.fc1 = nn.Linear(16, 64),
self.fc2 = nn.Linear(64, 10)
def forward(self, x):
x = nn.ReLU(self.maxp1(self.conv1(x)))
x = nn.ReLU(self.maxp2(self.conv1(x)))
x = x.view(x.size(0), -1)
x = nn.ReLu(self.fc1(x))
return self.fc2
What I was trying to do was ConvLayer- ReLu activation - Max Pooling 2x2 - ConvLayer - ReLu activation - Flatten Layer - Fully Connect - ReLu - Fully Connected
However, this gives me TypeError: 'tuple' object is not callable
on x = nn.ReLU(self.maxp1(self.conv1(x)))
How can I fix this?