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

Bugs of reloading model #165

Closed
hangtingchen opened this issue Jul 9, 2020 · 2 comments
Closed

Bugs of reloading model #165

hangtingchen opened this issue Jul 9, 2020 · 2 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@hangtingchen
Copy link
Contributor

🐛 Bug

Bugs of reloading model when best_k_models.json not exist

To Reproduce

https://github.com/mpariente/asteroid/blob/0bdec2644f2d770d037ce804b7f70cb98bd5c9fa/egs/wsj0-mix/DeepClustering/model.py#L156-L157

The lines use sort to get the last model, which will performs in a incorrect way in the following situation

>>> all_ckpt=['ckpt_epoch_99.ckpt','ckpt_epoch_100.ckpt','ckpt_epoch_101.ckpt']
>>> all_ckpt.sort()
>>> all_ckpt[-1]
'ckpt_epoch_99.ckpt'

Expected behavior

Maybe we can use the following methods:

>>> all_ckpt=[(ckpt,int("".join(filter(str.isdigit,os.path.basename(ckpt))))) for ckpt in all_ckpt if ckpt.find('ckpt')>=0]
>>> all_ckpt.sort(key=lambda x:x[1])
>>> all_ckpt[-1][0]
'ckpt_epoch_101.ckpt'

Environment

  • Python 3.7
@hangtingchen hangtingchen added bug Something isn't working help wanted Extra attention is needed labels Jul 9, 2020
@mpariente
Copy link
Collaborator

You're completely right, mind submitting a PR please?

@mpariente
Copy link
Collaborator

Solved by #166

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants