Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Differences in models #20

Open
lesolorzanov opened this issue Jun 22, 2024 · 0 comments
Open

Differences in models #20

lesolorzanov opened this issue Jun 22, 2024 · 0 comments

Comments

@lesolorzanov
Copy link

Hello. I've been using your model weights and it was all working fine a couple years ago. I was trying today and I was getting weird results and I noticed that your model's state_dict has weights for layers 'fc.1.bias', 'fc.1.weight', 'fc.3.bias', 'fc.3.weight' while the resnet definition I am using today as of 2024 contains only 'fc.bias', 'fc.weight'. I am assuming this is why it wasn't working.

While I can override and create those last fc layers, I was wondering if there is any "fc2" that existed before? I wonder if it would have been possible to put here the definition of the model, since pytorch themselves may and indeed seem to have changed the definition of the model.


model = torchvision.models.__dict__['resnet18'](pretrained=False)
model_dict = model.state_dict()
model_dict["fc.weight"].shape
> torch.Size([1000, 512])

MODEL_PATH = "pretrained_models/tenpercent_resnet18.ckpt"
state = torch.load(MODEL_PATH, map_location='cuda:0')
state_dict = state['state_dict']

for k in ['fc.1.weight', 'fc.1.bias', 'fc.3.weight', 'fc.3.bias']:
    print(state_dict[k].shape)

> torch.Size([512, 512])
> torch.Size([512])
> torch.Size([128, 512])
> torch.Size([128])


torchvision.__version__
> '0.8.2'
torch.__version__
> '1.7.1'
sys.version
> '3.6.10 | packaged by conda-forge | (default, Apr 24 2020, 16:44:11) \n[GCC 7.3.0]'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant