Timm learner and nasnet?

Has anyone been able to implement timm learner and nasnetalarge? I keep getting errors like:
TypeError: forward() missing 1 required positional argument: ‘x_stem_0’`

We need a reproducer… and the fallback would be to try using the raw timm library instead first, and see if it’s a bug in timm_learner (if you’re using wwf)

Here is what I was testing:

BTW. figured out how to make Colabs run 10x faster with files … glad you raised that Drive is an issue! Probably saved me days of my life!

Is nasnet special or different than the rest (of timm) to some degree? If so this can’t do it. So you should use the native timm library to make your model instead and then use Learner. Similar to what you need to do for the VIT model.

Ah, is there an example of someone using VIT this way?

Hi charliec, you can do this for ViT:

model = timm.create_model('vit_large_patch16_224', pretrained=True)
for param in model.parameters():
  param.requires_grad=True

n_classes=len(dls.train_ds.vocab)
outputs_attrs = n_classes
num_inputs = model.head.in_features
last_layer = nn.Linear(num_inputs, outputs_attrs)
model.head = last_layer

learner17May_50cl_vit_large_patch16_224=Learner(dls,model,metrics=[accuracy,
                                                        top_3_accuracy,
                                                        f1score,
                                                        prec,
                                                        rocauc],
                                    opt_func=ranger,model_dir=classes_50_models_path2)

Hope this helps.

2 Likes