Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Notebook fails to load pre-trained models #2

Open
taavi223 opened this issue Dec 7, 2020 · 2 comments
Open

Notebook fails to load pre-trained models #2

taavi223 opened this issue Dec 7, 2020 · 2 comments

Comments

@taavi223
Copy link

taavi223 commented Dec 7, 2020

I'm getting the following error in the Load the Trained Model from Checkpoint for Evaluation section when trying to load the pre-trained models in the repo.

# pick load folder  
load_folder = '/content/gdrive/My Drive/DL/models/checkpoints'  

# pick the epoch to load
epoch = '429'
model_name = f'parallel_all_you_wantFINAL-{epoch}.pkl'

# make full load path
load_path = os.path.join(load_folder, model_name)

## instantiate empty model and populate with params from binary 
model = parallel_all_you_want(len(emotions_dict))
load_checkpoint(optimizer, model, load_path)

print(f'Loaded model from {load_path}')

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
<ipython-input-51-de60b48d9410> in <module>
     11 ## instantiate empty model and populate with params from binary
     12 model = parallel_all_you_want(len(emotions_dict))
---> 13 load_checkpoint(optimizer, model, load_path)
     14 
     15 print(f'Loaded model from {load_path}')

<ipython-input-50-2469ccaf4901> in load_checkpoint(optimizer, model, filename)
     11 def load_checkpoint(optimizer, model, filename):
     12     checkpoint_dict = torch.load(filename, map_location=torch.device('cpu'))
---> 13     epoch = checkpoint_dict['epoch']
     14     model.load_state_dict(checkpoint_dict['model'])
     15     if optimizer is not None:

KeyError: 'epoch'

It appears that the pre-trained model files were not generated using the structure expected by the notebook.

@axe980703
Copy link

Same problem

@MuhammedTech
Copy link

same here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants