embeddings.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:wiki-sem-500 作者: belph 项目源码 文件源码
def load(fname):
    """Load an embedding dump generated by `save`"""

    content = _open(fname).read()
    if PY2:
      state = pickle.loads(content)
    else:
      state = pickle.loads(content, encoding='latin1')
    voc, vec = state
    if len(voc) == 2:
      words, counts = voc
      word_count = dict(zip(words, counts))
      vocab = CountedVocabulary(word_count=word_count)
    else:
      vocab = OrderedVocabulary(voc)
    return Embedding(vocabulary=vocab, vectors=vec)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号