How to make CNN performance better, CNN accuracy cannot convergent

Thank you for your quick reply, @J_Johnson . But I’m still confused about "combining input tensors to the output tensor" mentioned by @DoctorPolygon . Is the part referred to this:

def forward(self, x: Tensor) -> Tensor:
        identity = x
out += identity
out = self.relu(out)

You can run a process that crops the image using regular image processing techniques, especially if you always have that white background. The model won’t care if the image has slightly oddball aspect ratios, just try to maximize neurons spent on looking at the leaf.

Also, its generally not helpful when starting out in ML to create a custom architecture. Use something that already exists, like Resnet, Unet, and so on. There are many more people much smarter than you or I that only do R&D and create these blocks and modules.
A Resnet can use depthwise conv just fine, I’d recommend you read more papers like the original ResNet and EfficientNet documents that go into more detail than I care to go into here.

Thank you, can you help me create a technique for cropping that image?

Finding the bounds is a basic computer vision task, recommend you study the topic more in general so you are more familiar with the domain and what you are trying to do in general.

Hello, I’m using ResNet18 and I obtained the following results.
score
cost

Is there anything that needs to be changed to achieve the desired loss results?
WhatsApp Image 2023-06-27 at 12.01.09

You’re getting overfitting after epoch 10. You should save before the train loss falls below the test loss.

Hello, is it correct to use the RestNet18 architecture?

import torchvision.models as models
class RestNet18transferL(nn.Module):
    def __init__(self, output_size):
        super().__init__()
        self.net = models.resnet18(weights=models.ResNet18_Weights.DEFAULT)
        
        self.freeze()
        
        self.net.fc = nn.Sequential(
            nn.Linear(512, output_size),
            nn.Dropout(0.5)
        )
        
    def forward(self, x):
        return self.net(x)
        
    def freeze(self):
        for param in self.net.parameters():
            param.requires_grad = False