I have trained the doc2vec model models_by_name['dbow+dmm'].
I have made predictions with it an I am satisfied with its performance.
I want it to persist. I tried to save it with the command below.
models_by_name['dbow+dmm'].save('dbow+dmm.doc2vec')
I got the following wrror message.
AttributeError Traceback (most recent call last)
----> 1 models_by_name['dbow+dmm'].save('dbow+dmm.doc2vec')
2 # model = Doc2Vec.load(fname) # you can continue training with the loaded model!
AttributeError: 'ConcatenatedDoc2Vec' object has no attribute 'save'
How do I save a 'ConcatenatedDoc2Vec' doc2vec model?
Thanks!
Hello @stagOak, ConcatenatedDoc2Vec is wrapper-only class, this doesn't provide save/load functionality.
If you want to save it, you can try to use pickle (or save all models from self.models calling save attribute for each model & load all models & create ConcatenatedDoc2Vec again)
Thanks! I should have checked out the code. Late last night I found a work around. Thought I would share.
I made the model with:
models_by_name['dbow+dmm'] = ConcatenatedDoc2Vec([simple_models[1], simple_models[2]])
I save the model with:
simple_models[1].save('toxic_1.doc2vec')
simple_models[2].save('toxic_2.doc2vec')
I loaded the model with:
model_1 = Doc2Vec.load('toxic_1.doc2vec')
model_2 = Doc2Vec.load('toxic_2.doc2vec')
I recreated the model with:
model_1_2 = ConcatenatedDoc2Vec([model_1, model_2])
It repeated my earlier predictions.
I wish to credit a great tutorial for doc2vec:
https://github.com/RaRe-Technologies/gensim/blob/develop/docs/notebooks/doc2vec-IMDB.ipynb
Thanks again for your support!
Most helpful comment
Thanks! I should have checked out the code. Late last night I found a work around. Thought I would share.
I made the model with:
I save the model with:
I loaded the model with:
I recreated the model with:
It repeated my earlier predictions.
I wish to credit a great tutorial for doc2vec:
https://github.com/RaRe-Technologies/gensim/blob/develop/docs/notebooks/doc2vec-IMDB.ipynb
Thanks again for your support!