I'm having a problem trying to load a Pytoch model: "Can't find Identity in module"
When trying to load a pytorch model it gives the following attribute error
model = torch.load('../input/melanoma-model/melanoma_model_0.pth')
model = model.to(device)
model.eval()


AttributeError                            Traceback (most recent call
last)  in 
1 arch = EfficientNet.from_pretrained('efficientnet-b2')
2 model = Net(arch=arch)
----&gt; 3 torch.load('../input/melanoma-model/melanoma_model_0.pth')
4 model = model.to(device)
5 model.eval()
/opt/conda/lib/python3.7/site-packages/torch/serialization.py in
load(f, map_location, pickle_module, **pickle_load_args)
591                     return torch.jit.load(f)
592                 return _load(opened_zipfile, map_location, pickle_module, **pickle_load_args)
--&gt; 593         return _legacy_load(opened_file, map_location, pickle_module, **pickle_load_args)
594
595
/opt/conda/lib/python3.7/site-packages/torch/serialization.py in
_legacy_load(f, map_location, pickle_module, **pickle_load_args)
771     unpickler = pickle_module.Unpickler(f, **pickle_load_args)
772     unpickler.persistent_load = persistent_load
--&gt; 773     result = unpickler.load()
774
775     deserialized_storage_keys = pickle_module.load(f, **pickle_load_args)
AttributeError: Can't get attribute 'Identity' on &lt;module
'efficientnet_pytorch.utils' from
'/opt/conda/lib/python3.7/site-packages/efficientnet_pytorch/utils.py'&gt;


First you need a model class to load the parameters from the .pth into. And you are missing one step:
model = Model()   # the model class (yours has probably another name)
model.load_state_dict(torch.load('../input/melanoma-model/melanoma_model_0.pth'))
model = model.to(device)
model.eval()

There you go, I hope that solved your problem!
