KeyError: "filename 'storages' not found"
I'm trying to load pre-trained model weights using this line :

state_dict = torch.load('models/seq_to_txt_state_7.tar')


and I'm getting:

       KeyError                                  Traceback (most recent call last)
&lt;ipython-input-30-3f7b5be8fc72&gt; in &lt;module&gt;()
----&gt; 1 state_dict = torch.load('models/seq_to_txt_state_7.tar')

/home/arash/venvs/marzieh_env/local/lib/python2.7/site-packages/torch/serialization.pyc in load(f, map_location, pickle_module)
    365         f = open(f, 'rb')
    366     try:
--&gt; 367         return _load(f, map_location, pickle_module)
    368     finally:
    369         if new_fd:

/home/arash/venvs/marzieh_env/local/lib/python2.7/site-packages/torch/serialization.pyc in _load(f, map_location, pickle_module)
    521         # only if offset is zero we can attempt the legacy tar file loader
    522         try:
--&gt; 523             return legacy_load(f)
    524         except tarfile.TarError:
    525             # if not a tarfile, reset file offset and proceed

/home/arash/venvs/marzieh_env/local/lib/python2.7/site-packages/torch/serialization.pyc in legacy_load(f)
    448                 mkdtemp() as tmpdir:
    449 
--&gt; 450             tar.extract('storages', path=tmpdir)
    451             with open(os.path.join(tmpdir, 'storages'), 'rb', 0) as f:
    452                 num_storages = pickle_module.load(f)

/usr/lib/python2.7/tarfile.pyc in extract(self, member, path)
   2107 
   2108         if isinstance(member, basestring):
-&gt; 2109             tarinfo = self.getmember(member)
   2110         else:
   2111             tarinfo = member

/usr/lib/python2.7/tarfile.pyc in getmember(self, name)
   1827         tarinfo = self._getmember(name)
   1828         if tarinfo is None:
-&gt; 1829             raise KeyError("filename %r not found" % name)
   1830         return tarinfo
   1831 

KeyError: "filename 'storages' not found"


I'm using python 2.7 on Ubuntu 18.

In addition the model is saved using this function in first place:

def save_state(enc, dec, enc_optim, dec_optim, dec_idx_to_word, dec_word_to_idx, epoch):
state = {'enc':enc.state_dict(), 'dec':dec.state_dict(),
         'enc_optim':enc_optim.state_dict(), 'dec_optim':dec_optim.state_dict(),
        'dec_idx_to_word':dec_idx_to_word, 'dec_word_to_idx':dec_word_to_idx}
torch.save(state, epoch_to_save_path(epoch))


@reportgunner is right. The model file was corrupted. End of the message!
