using transfer learning model on resnet18
Opened this issue · 3 comments
I build a resnet18 transfer learning model following the example in weblink: https://pytorch.org/tutorials/beginner/transfer_learning_tutorial.html.
My program encounters the error when running to:
meta_model.update_params(hyperparameters['lr'], source_params=grads)
The error is: TypeError: cannot assign 'torch.cuda.FloatTensor' as parameter 'weight' (torch.nn.Parameter or None expected)
Anyone has ideas about the error I encountered? Thanks
Could you give the exact link for: class MetaModule(nn.Module): ?
I have not found it from: Adrien Ecoffet https://github.com/AdrienLE
You need to change the code. You can find it from here
You need to change the code. You can find it from here
I had change nn.Module to MetaModule in PreActResNetMeta class and linear line in that class according to the instruction, but there is still similar error. Did you change anything else?
I have encountered the same error, and I have figured out why: you need to rewrite all nn functions including trainable parameters in ResNet layers to "Meta"-like style. Just like MetaConv2d, MetaLinear, you need to write a new MetaBatchnorm function and replace the original nn functions.