Hello, I was able to run successfully this tutorial with pytorch ignite
https://www.kaggle.com/hmendonca/multitask-efficientnetb4-ignite-amp-clr-aptos19 4
but in order to do a pruning method I need to save the whole model (state dict is not useful), and I try to save with torch.save(model,‘model1.pth’) for example and I get the following message:
File “”, line 1, in
torch.save(model,‘modelo_ejemplo1.pth’)
File “C:\ProgramData\Anaconda3\lib\site-packages\torch\serialization.py”, line 260, in save
return _with_file_like(f, “wb”, lambda f: _save(obj, f, pickle_module, pickle_protocol))
File “C:\ProgramData\Anaconda3\lib\site-packages\torch\serialization.py”, line 185, in _with_file_like
return body(f)
File “C:\ProgramData\Anaconda3\lib\site-packages\torch\serialization.py”, line 260, in
return _with_file_like(f, “wb”, lambda f: _save(obj, f, pickle_module, pickle_protocol))
File “C:\ProgramData\Anaconda3\lib\site-packages\torch\serialization.py”, line 332, in _save
pickler.dump(obj)
AttributeError: Can’t pickle local object ‘_initialize…patch_forward…new_fwd’
I’ve been looking a lot about this error message, but anyone seems to use ignite a lot…
I can save the model like this
to_save = {‘model’: model}
handler = Checkpoint(to_save, DiskSaver(‘D:\Neural_Nets\EfficientNet\Pytorch\CIFAR10b’, create_dir=True,require_empty=False), n_saved=2)
trainer.add_event_handler(Events.EPOCH_STARTED, handler)
but I can only save the weights…I want to save the whole model like I do with other codes that don’t use this pytorch ignite…can you help me with this issue? I think ignite is more efficient than my other way of training, that is why I want to change to it but if I can’t save the model there is no case 
Thanks in advance!