AntixK / PyTorch-Model-Compare

Compare neural networks by their feature similarity
MIT License
342 stars 37 forks source link

ValueError: Input image size (32*32) doesn't match model (224*224). #13

Open ratom opened 1 year ago

ratom commented 1 year ago

I tried to compare Resnet50 vs ViT but got this error ValueError: Input image size (3232) doesn't match model (224224). The code I used is

model1 = resnet50(pretrained=False) layers_Res1 = list(model1.children()) model1 = nn.Sequential(*layers_Res1[:-1])

model2 = resnet34(pretrained=True)

config = ViTConfig() model2 = ViTModel(config)

Create a new model with the last two layers removed

layers_trans = list(model2.children()) model2 = nn.Sequential(*layers_trans[:-2])

cka = CKA(model1, model2, model1_name="ResNet50", model2_name="ViT-B")

,device='cuda')

cka.compare(dataloader)

cka.plot_results(save_path="/content/drive/MyDrive/resnet50vit-b.png")

bryanbocao commented 8 months ago

Try specifying dataloader2 for model2.