Calculate perplexity of word2vec model

牧云@^-^@ 提交于 2020-01-15 04:51:53

问题


I trained Gensim W2V model on 500K sentences (around 60K) words and I want to calculate the perplexity.

  1. What will be the best way to do so?
  2. for 60K words, how can I check what will be a proper amount of data?

Thanks


回答1:


If you want to calculate the perplexity, you have first to retrieve the loss. On the gensim.models.word2vec.Word2Vec constructor, pass the compute_loss=True parameter - this way, gensim will store the loss for you while training. Once trained, you can call the get_latest_training_loss() method to retrieve the loss.

Since the loss in the cross-entropy loss of the skip-gram model, 2 to the power of the loss will give you the preplexity. (2**loss)



来源:https://stackoverflow.com/questions/53765598/calculate-perplexity-of-word2vec-model

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!