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

ImportError: No module named loader #1

Closed
AmitMY opened this issue Sep 18, 2018 · 5 comments
Closed

ImportError: No module named loader #1

AmitMY opened this issue Sep 18, 2018 · 5 comments

Comments

@AmitMY
Copy link
Contributor

AmitMY commented Sep 18, 2018

Thanks for this code.

First, the README is missing two dependencies: matplotlib and scipy.

When running the command from the README, I get an error:

Traceback (most recent call last):
File "lattice.py", line 2, in
import msa_class
File "/home/nlp/amit/pseudo-ref/msa_class.py", line 15, in
import loader
ImportError: No module named loader

I am assuming that that is because of

sys.path.append('../pytorch-examples/word_language_model/')

But I haven't found any indication in https://github.com/pytorch/examples/tree/master/word_language_model of a loader.

Can you please add instructions on how to get loader? or maybe add it to this repo as well?

@renj
Copy link
Owner

renj commented Sep 18, 2018

Thank you Amit for pointing out this bug. loader actually is in language_model. I've just fixed this.

@AmitMY
Copy link
Contributor Author

AmitMY commented Sep 18, 2018

Great, thanks!
One more dependency missing is nltk.

Also, it now fails to import Model:

========= READ DATA COMPLETE ===========
Traceback (most recent call last):
File "lattice.py", line 607, in
lm_model = torch.load(f, map_location=lambda storage, loc: storage)
File "/home/nlp/amit/anaconda2/envs/pseudo-ref/lib/python2.7/site-packages/torch/serialization.py", line 358, in load
return _load(f, map_location, pickle_module)
File "/home/nlp/amit/anaconda2/envs/pseudo-ref/lib/python2.7/site-packages/torch/serialization.py", line 542, in _load
result = unpickler.load()
ImportError: No module named Model

@renj
Copy link
Owner

renj commented Sep 18, 2018

It's fixed now. language_model should be added into path.

@AmitMY
Copy link
Contributor Author

AmitMY commented Sep 18, 2018

Thanks. This works! I am running the soft code overnight, as it seems to take seconds for some sentences, but many minutes for others, but I ran it on a sample and it worked.

@AmitMY AmitMY closed this as completed Sep 18, 2018
@renj
Copy link
Owner

renj commented Sep 18, 2018

Thanks. This works! I am running the soft code overnight, as it seems to take seconds for some sentences, but many minutes for others, but I ran it on a sample and it worked.

Yes. If the lattice is complex, it will take a long time to generate the pseudo-sentences. Actually you can do some optimization on it, e.g. cache the suffixes of each nodes instead of simple DFS.

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

2 participants