[Python] Overfitting in CNN model [closed]

Discussão em 'Python' iniciado por Stack, Outubro 24, 2024.

  1. Stack

    Stack Membro Participativo

    I have been doing the project of Knee osteoarthritis severity grading and using Cnn ( Can't use pretrained model). I am using the dataset of kaggle. I used 3 convolutional layer with 2 pooling layer .But I am facing over fitting .Most of the data in my class 1 are predicted as 0 and 2 and so is class 4 .

    I implemented smote class weight used different augmentations batchnormalization dropouts ,tried different learning rates , scheduler but it doesn't improve a bit . What should I do next ? this is my model without any dropouts or normalization.

    class SimpleCNN(nn.Module):
    def __init__(self,num_classes):
    super(SimpleCNN,self).__init__()
    self.conv1 = nn.Conv2d(1,64,kernel_size=3,padding=1)
    self.relu1 = nn.ReLU()
    self.pool1 = nn.MaxPool2d(kernel_size=2,stride=2)

    self.conv2 = nn.Conv2d(64,64,kernel_size=3,padding=1)
    self.relu2 = nn.ReLU()
    self.pool2 = nn.MaxPool2d(kernel_size=2,stride=2)

    self.conv3 = nn.Conv2d(64,64,kernel_size=3,padding=1)
    self.relu3 = nn.ReLU()
    self.pool3 = nn.MaxPool2d(kernel_size=2,stride=2)

    self.flatten = nn.Flatten()
    self.fc1 = nn.Linear(40000,1024)
    self.relu4 = nn.ReLU()
    self.fc2 = nn.Linear(1024,num_classes)

    def forward(self,x):
    x = self.pool1(self.relu1(self.conv1(x)))

    x = self.pool2(self.relu2(self.conv2(x)))
    x = self.pool3(self.relu3(self.conv3(x)))
    # print(x.size())

    x = self.flatten(x)
    x = self.relu4(self.fc1(x))
    x = self.fc2(x)

    return x

    Continue reading...

Compartilhe esta Página