I’m trying to load a .pt/.pth file with torch.load. Having worked perfectly previously, after adding another item to my instance before creating the .pt file again, this error popped up. Full error is:
Traceback (most recent call last):
File “outcome.py”, line 12, in
torch.load(r"path")
File “C:\Users\Flawnson\Anaconda3\lib\site-packages\torch\serialization.py”, line 368, in load
return _load(f, map_location, pickle_module)
File “C:\Users\Flawnson\Anaconda3\lib\site-packages\torch\serialization.py”, line 549, in _load
deserialized_objects[key]._set_from_file(f, offset, f_should_read_directly)
RuntimeError: storage has wrong size: expected 0 got 1
By “adding another item to my instance” do you mean you’ve added another module to your model?
Could you post some pseudo code so that we could see what’s going on?
The same error with torch.load occurred to me after I mistakenly set the size of unused embedding layer to 0. This network consumed a day of computational time. Could there be a way to bypass the error and load it (maybe ignoring empty layer)?
The same error with torch.load occurred to me. Many methods were tried but all failed. Finally, I downloaded the weight file <xxx.pth> again and succeeded…