materialsintelligence / mat2vec

Supplementary Materials for Tshitoyan et al. "Unsupervised word embeddings capture latent knowledge from materials science literature", Nature (2019).
MIT License
616 stars 180 forks source link

No module named 'helpers' error when loading newly trained embeddings #10

Closed lfoppiano closed 5 years ago

lfoppiano commented 5 years ago

Dear all, I've trained my own embeddings and I'm now trying to open using your mat2vec tool using

 w2v_model = Word2Vec.load(....)

however I get a strange error about a module helpers. This same problem does not happens with the pre-trained models you are providing:

>>> w2v_model = Word2Vec.load("mat2vec/training/models/pretrained_embeddings")
>>> w2v_model = Word2Vec.load("mat2vec/training/models/test_model")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/anaconda3/envs/mat2vec/lib/python3.6/site-packages/gensim/models/word2vec.py", line 975, in load
    return super(Word2Vec, cls).load(*args, **kwargs)
  File "/anaconda3/envs/mat2vec/lib/python3.6/site-packages/gensim/models/base_any2vec.py", line 629, in load
    model = super(BaseWordEmbeddingsModel, cls).load(*args, **kwargs)
  File "/anaconda3/envs/mat2vec/lib/python3.6/site-packages/gensim/models/base_any2vec.py", line 278, in load
    return super(BaseAny2VecModel, cls).load(fname_or_handle, **kwargs)
  File "/anaconda3/envs/mat2vec/lib/python3.6/site-packages/gensim/utils.py", line 425, in load
    obj = unpickle(fname)
  File "/anaconda3/envs/mat2vec/lib/python3.6/site-packages/gensim/utils.py", line 1332, in unpickle
    return _pickle.load(f, encoding='latin1')
  File "/Users/lfoppiano/development/github/mat2vec/mat2vec/training/__init__.py", line 1, in <module>
    from helpers import utils
ModuleNotFoundError: No module named 'helpers'
>>> 

Any suggestion?

Another question, after the training, I have only accuracies, loss and phraser in my model output directory. I copied the files containing vectors, trainable and the actual model from the tmp directory (I took the one of epoque29), was this the correct way?

.rw-r--r-- lfoppiano staff 286.4 MB Mon Aug  5 11:33:58 2019   test_model
.rw-r--r-- lfoppiano staff   3.2 GB Mon Aug  5 11:33:24 2019   test_model.trainables.syn1neg.npy
.rw-r--r-- lfoppiano staff   3.2 GB Mon Aug  5 11:39:55 2019   test_model.wv.vectors.npy
.rw-r--r-- lfoppiano staff   7.5 KB Mon Aug  5 11:26:21 2019   test_model_accuracies.pkl
.rw-r--r-- lfoppiano staff   389 B  Mon Aug  5 11:27:07 2019   test_model_loss.pkl
.rw-r--r-- lfoppiano staff    53 MB Mon Aug  5 11:40:00 2019   test_model_phraser.pkl
lfoppiano commented 5 years ago

I just realised I pasted the wrong error message. I've edited the issue, in principle by loading my embeddings, I get: ModuleNotFoundError: No module named 'helpers'

jdagdelen commented 5 years ago

Hi Luca, thanks for getting in touch. I'll try to replicate the error.

vtshitoyan commented 5 years ago

Can you try loading the model from the training directory, after cd mat2vec/training ?

vtshitoyan commented 5 years ago

@lfoppiano let us know if you still have the issue, but #12 should have fixed it.

lfoppiano commented 5 years ago

I can confirm that the issue is fixed. Thank you!