huggingface / pytorch-image-models

The largest collection of PyTorch image encoders / backbones. Including train, eval, inference, export scripts, and pretrained weights -- ResNet, ResNeXT, EfficientNet, NFNet, Vision Transformer (ViT), MobileNetV4, MobileNet-V3 & V2, RegNet, DPN, CSPNet, Swin Transformer, MaxViT, CoAtNet, ConvNeXt, and more
https://huggingface.co/docs/timm
Apache License 2.0
31.95k stars 4.73k forks source link

mat1 and mat2 shapes can not be multiplies #1663

Closed keertika-11 closed 1 year ago

keertika-11 commented 1 year ago

Describe the bug I am working on a script to finetune the"coatnet_2_rw_224.sw_in12k_ft_in1k" model, but I am encountering matrix multiplication error

To Reproduce

model = timm.create_model("coatnet_2_rw_224.sw_in12k_ft_in1k", pretrained=True, num_classes=3, scriptable=True,
                              exportable=True).get_classifier()
model.fc = torch.nn.Sequential(torch.nn.Linear(in_features=model.in_features, out_features=3, bias=True))
for epoch in range(2):
    for batch in train_loader:
        inputs, targets = batch
        outputs = model(inputs)
Screenshot 2023-02-07 at 07 31 29

Desktop (please complete the following information):

keertika-11 commented 1 year ago

Removed the line model.fc = torch.nn.Sequential(torch.nn.Linear(in_features=model.in_features, out_features=3, bias=True)) works