DSE-MSU / DeepRobust

A pytorch adversarial library for attack and defense methods on images and graphs
MIT License
994 stars 192 forks source link

torch.load raise ModuleNotFoundError: No module named 'DeepRobust' #29

Closed ToTDream closed 4 years ago

ChandlerBang commented 4 years ago

Could you provide more details about the problem you met? Maybe you can copy your code so we can reproduce the problem.

ToTDream commented 4 years ago

Sorry. I just run the Test Examples.

$ python examples/image/test_PGD.py Load network Traceback (most recent call last): File "examples/image/test_PGD.py", line 18, in
model.load_state_dict(torch.load("./trained_models/CIFAR10_ResNet18_epoch_50.pt")) File "C:\Users\hasee\Anaconda3\envs\python36\lib\site-packages\torch\serialization.py", line 593, in load return _legacy_load(opened_file, map_location, pickle_module, **pickle_load_args) File "C:\Users\hasee\Anaconda3\envs\python36\lib\site-packages\torch\serialization.py", line 773, in _legacy_load
result = unpickler.load() ModuleNotFoundError: No module named 'DeepRobust'

And I also wonder why it has something to do with “DeepRobust”. Maybe I didn’t install it successfully? Thank you for your attention!

YaxinLi0-0 commented 4 years ago

Thank you for reporting this question to us. That's because the model 'CIFAR10_ResNet18_epoch_50.pt' is generated by the old version of DeepRobust, the model file is mismatched with the model class "resnet.ResNet18()". You can try this model file instead: https://github.com/I-am-Bot/deeprobust_model/blob/master/CIFAR10_ResNet18_epoch_20.pt. Make sure you have the model file under the correct path. BTW, I fix a small bug in this file, please update.

ToTDream commented 4 years ago

Thank you so much!