the input size of image is [3, 224, 224] and batch size is 64. It keeps showing this error:
mat1 dim 1 must match mat2 dim 0
class SimpleBNConv(nn.Module):
# This constructor will initialize the model architecture
def __init__(self):
super(SimpleBNConv, self).__init__()
self.cnn_layers = nn.Sequential(
# Defining a 2D convolution layer
nn.Conv2d(3, 8, kernel_size=3, stride=1, padding=1),
# Putting a 2D Batchnorm after CNN layer
nn.BatchNorm2d(8),
# Adding Relu Activation
nn.ReLU(inplace=True),
nn.Conv2d(8, 8, kernel_size=3, stride=1, padding=1),
nn.BatchNorm2d(8),
nn.ReLU(inplace=True),
nn.MaxPool2d(kernel_size=2, stride=2),
nn.Conv2d(8, 16, kernel_size=3, stride=1, padding=1),
# Putting a 2D Batchnorm after CNN layer
nn.BatchNorm2d(16),
# Adding Relu Activation
nn.ReLU(inplace=True),
nn.Conv2d(16, 16, kernel_size=3, stride=1, padding=1),
nn.BatchNorm2d(16),
nn.ReLU(inplace=True),
nn.MaxPool2d(kernel_size=2, stride=2),
nn.Conv2d(16, 32, kernel_size=3, stride=1, padding=1),
# Putting a 2D Batchnorm after CNN layer
nn.BatchNorm2d(32),
# Adding Relu Activation
nn.ReLU(inplace=True),
nn.Conv2d(32, 32, kernel_size=3, stride=1, padding=1),
nn.BatchNorm2d(32),
nn.ReLU(inplace=True),
nn.MaxPool2d(kernel_size=2, stride=2),
nn.Conv2d(32, 64, kernel_size=3, stride=1, padding=1),
# Putting a 2D Batchnorm after CNN layer
nn.BatchNorm2d(64),
# Adding Relu Activation
nn.ReLU(inplace=True),
nn.Conv2d(64, 64, kernel_size=3, stride=1, padding=1),
nn.BatchNorm2d(64),
nn.ReLU(inplace=True),
nn.MaxPool2d(kernel_size=2, stride=2),
nn.Conv2d(64, 128, kernel_size=3, stride=1, padding=1),
# Putting a 2D Batchnorm after CNN layer
nn.BatchNorm2d(128),
# Adding Relu Activation
nn.ReLU(inplace=True),
nn.Conv2d(128, 128, kernel_size=3, stride=1, padding=1),
nn.BatchNorm2d(128),
nn.ReLU(inplace=True),
nn.MaxPool2d(kernel_size=2, stride=2),
nn.Flatten(),
nn.Linear(10976, 6272),
nn.ReLU(inplace=True),
nn.Linear(6272, 7)
)
# Defining the forward pass
def forward(self, x):
# Forward Pass through the CNN Layers
x = self.cnn_layers(x)
return nn.functional.softmax(x)