lukemelas / EfficientNet-PyTorch

A PyTorch implementation of EfficientNet
Apache License 2.0
7.86k stars 1.52k forks source link

TypeError: from_name() got an unexpected keyword argument 'num_classes' #155

Open weizhenFrank opened 4 years ago

weizhenFrank commented 4 years ago

Thanks for your great effort in the implementation of efficientnet in pytorch which provide huge convenience for me. But when I use model by EfficientNet.from_name("efficientnet-b1",num_classes=2), it raised error "TypeError: from_name() got an unexpected keyword argument 'num_classes'". As I want use my own dataset to train the model from scratch, could you do me a favor?

Ryo-F commented 4 years ago

@weizhenFrank I had the same problem. EfficientNet.from_name("efficientnet-b1", {"num_classes": 2}) worked for me. .from_name() loads parameters from dictionary. https://github.com/lukemelas/EfficientNet-PyTorch/blob/d8481a539cc1f84ef0fe502f9c12dcc187669611/efficientnet_pytorch/model.py#L203