i have 120 classes which contain almost 20k images of dogs. so my assignment is to code 2 xtra convolution layers with 1 batch normalization layer. the code is working fine on cifar-10 class, but when i use mine class it gives different error. as you said this line shouldn’t be here. i commented it and get this error.
import torch.nn as nn
import torch.nn.functional as F


class Net(nn.Module):
    def __init__(self):
        super(Net, self).__init__()
        self.conv1 = nn.Conv2d(in_channels=3,out_channels=6,kernel_size=11)
        self.pool = nn.MaxPool2d(2, 2)
        self.conv2 = nn.Conv2d(in_channels=6,out_channels=12,kernel_size=11)
        self.conv3 = nn.Conv2d(in_channels=12,out_channels=24,kernel_size=11)
        self.conv4 = nn.Conv2d(in_channels=24,out_channels=48,kernel_size=11)
        self.conv2_bn = nn.BatchNorm2d(48)

        self.fc1 = nn.Linear(49152, 360)
        self.fc2 = nn.Linear(360, 240)
        self.fc3 = nn.Linear(240, 120)

    def forward(self, x):
        x = self.pool(F.relu(self.conv1(x)))
        x = self.pool(F.relu(self.conv2(x)))
        x = self.pool(F.relu(self.conv3(x)))
        x = self.pool(F.relu(self.conv4(x)))
        #x = F.relu(F.max_pool2d(self.conv2_bn(self.conv4(x))))
        x = x.view(-1, 49152 )
        x = F.relu(self.fc1(x))
        x = F.relu(self.fc2(x))
        x = self.fc3(x)
        return x


net = Net()

error21442×387 107 KB