Add layers to ResNet18

Hello everyone for my research I have to make some experiments with a Git-Repo.

So I should Experiment with the project where I add additional layers to the ResNet18 and try some different activation-functions. They almost use relu.
To be honest im not good with PyTorch, I just have some experience with Yolo and that’s it.

Can you guys help me to solve this task?

Could you describe where exactly you are stuck and what kind of assignment this is? I’m more than happy to help you out in case you are stuck at a specific point or don’t understand some PyTorch ops, but we should not solve homework or other assignments.

You got it wrong, I don’t want you to do the entire task for me, I have read up on how to add additional layers. But when I look at the Git project, there are several ResNet files. And I don’t know which one I need to edit

Which model definitions are you using? I would start by checking your imports to check which file needs to be edited.

What did you mean with definitions.
So I almost know that I have modify the train.py and I think the resent.py but the thing what confuses me is, that in the resnet.pay are many models see picture

Somewhere in your code you are most likely defining model = resnet() where resnet would correspond to the model definition. Search for this class in your source files and check which modules are used internally to understand what needs to be changed.

1 Like

Please correct me if I am wrong. In this project several models and attacks are tested.
When I run the Train.py I also have to select the architecture (see picture)
Normally I would have to add the argument r18mod to the Train.pay and put this model in the folder nets ?

So i have solve it.
But now I don’t know why the train.py don’t use the total gpu power

I’m about to go crazy. Yesterday everything worked perfectly and today it doesn’t even though I haven’t changed anything since then. The training is always stuck at epoch 0.

here is my loader:

def get_loader(args, train_dataset, test_dataset):
    if args.dataset == "imagenet100":
        train_loader = torch.utils.data.DataLoader(
            train_dataset, batch_size=args.bs, shuffle=True, num_workers=4, drop_last=True
        )
        test_loader = torch.utils.data.DataLoader(
            test_dataset, batch_size=args.bs, shuffle=True, num_workers=4
        )
    else:
        train_loader = torch.utils.data.DataLoader(
            train_dataset, batch_size=args.bs, shuffle=False, num_workers=8, drop_last=True
        )
        test_loader = torch.utils.data.DataLoader(
            test_dataset, batch_size=args.bs, shuffle=False, num_workers=8
        )
    return train_loader, test_loader