resnet

Fine tuning resnet18 for cifar10

Fine tuning resnet18 for cifar10 Question: I just want fine tuning ResNet18 on cifar10 datasets. so I just want to change the last linear layer from 1000 to 10. I tried use children function to get the previous layers ResModel = resnet18(weights=ResNet18_Weights) model = nn.Sequential( *list(ResModel.children())[:-1], nn.Linear(512,10) ) so it raised error RuntimeError: mat1 and …

Total answers: 1

RuntimeError: The size of tensor a (38) must match the size of tensor b (34) at non-singleton dimension 3

RuntimeError: The size of tensor a (38) must match the size of tensor b (34) at non-singleton dimension 3 Question: I studied Resnet 50 using cifar-10 but, I faced RuntimeError. Here is code class BasicBlock(nn.Module): def __init__(self, in_planes, planes, stride = 1): super(BasicBlock, self).__init__() self.conv1 = nn.Conv2d(in_planes, planes, kernel_size = 1, stride = stride, padding …

Total answers: 1

Meaning of output shapes of ResNet9 model layers

Meaning of output shapes of ResNet9 model layers Question: I have a ResNet9 model, implemented in Pytorch which I am using for multi-class image classification. My total number of classes is 6. Using the following code, from torchsummary library, I am able to show the summary of the model, seen in the attached image: INPUT_SHAPE …

Total answers: 2

Multiple input model with PyTorch – input and output features

Multiple input model with PyTorch – input and output features Question: Good afternoon! I’m building a multiple-input model with 2 types of inputs: Images (torch.Size([1, 3, 224, 224])) and landmark features (torch.Size([1, 96])). Here’s the model itself: class MixedNetwork(nn.Module): def __init__(self): super(MixedNetwork, self).__init__() image_modules = list(models.resnet50().children())[:-1] self.image_features = nn.Sequential(*image_modules) self.landmark_features = nn.Sequential( nn.Linear(in_features=96, out_features=192,bias=False), nn.ReLU(inplace=True), …

Total answers: 1

Problems with using ResNet50

Problems with using ResNet50 Question: I know that reshape problems are a basic thing and that there are a lot of solutions out there, but I can’t find one that works for me. I’m currently trying to use ResNet50 to train with the Iceberg challenge (https://www.kaggle.com/competitions/statoil-iceberg-classifier-challenge): import numpy as np, pandas as pd from tensorflow.keras.optimizers …

Total answers: 1

Difference between forward and train_step in Pytorch Lightning?

Difference between forward and train_step in Pytorch Lightning? Question: I have a transfer learning Resnet set up in Pytorch Lightning. the structure is borrowed from this wandb tutorial https://wandb.ai/wandb/wandb-lightning/reports/Image-Classification-using-PyTorch-Lightning–VmlldzoyODk1NzY and from looking at the documentation https://pytorch-lightning.readthedocs.io/en/latest/common/lightning_module.html I am confused about the difference between the def forward () and the def training_step() methods. Initially in the …

Total answers: 3

What type of input does ResNet need?

What type of input does ResNet need? Question: I am new to deep learning, and I am trying to train a ResNet50 model to classify 3 different surgical tools. The problem is that every article I read tells me that I need to use 224 X 224 images to train ResNet, but the images I …

Total answers: 1

Extract features from pretrained resnet50 in pytorch

Extract features from pretrained resnet50 in pytorch Question: Hy guys, i want to extract the in_features of Fully connected layer of my pretrained resnet50. I create before a method that give me the vector of features: def get_vector(image): #layer = model._modules.get(‘fc’) layer = model.fc my_embedding = torch.zeros(2048) #2048 is the in_features of FC , output …

Total answers: 2

How to remove the last FC layer from a ResNet model in PyTorch?

How to remove the last FC layer from a ResNet model in PyTorch? Question: I am using a ResNet152 model from PyTorch. I’d like to strip off the last FC layer from the model. Here’s my code: from torchvision import datasets, transforms, models model = models.resnet152(pretrained=True) print(model) When I print the model, the last few …

Total answers: 4