Guest User

Untitled

a guest
May 28th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. from gensim.models import Doc2Vec
  2. import pickle
  3.  
  4. with open('./docs_proc.pkl', 'rb') as file:
  5. docs = pickle.load(file)
  6.  
  7. model = Doc2Vec(docs, vector_size = 500, window = 9, min_count = 20, workers=8, dm=0)
  8. with open('./d2v_model.pkl', 'wb') as file:
  9. pickle.dump(model, file)
  10.  
  11. epochs = 5
  12. start_alpha = 0.025
  13. end_alpha = 0.0001
  14. alpha_change = (start_alpha-end_alpha)/epochs
  15. assert gensim.models.doc2vec.FAST_VERSION > -1
  16. for i in range(epochs):
  17. print('Epoch', i)
  18. model.train(docs, total_examples=model.corpus_count, epochs=1)
  19. model.alpha -= alpha_change
  20. model.min_alpha = model.alpha
  21.  
  22. with open('./d2v_model_trained.pkl', 'wb') as file:
  23. pickle.dump(model, file)
Add Comment
Please, Sign In to add comment