手套蟒蛇绑定
glove-p的Python项目详细描述
glove py是用于从语料库中学习单词向量的glove算法的实现。
##安装
使用pip:pip install glove-py
。
使用github代码安装:
git clone git@github.com:f20500909/glove_py.git
python3 setup.py install
from glove import *
model = Glove(epoch=2)
model.train("small_text")
model.to_txt()
words = model.most_similary("one", 10)
print(words)
在shell中使用
skipgram模型
训练和加载skipgram模型
fromgloveimport*model=Glove(params)model.train(input_file)model.to_txt()words=model.most_similary("one",10)print(words)
可用params
及其默认值的列表:
help info......
-input_file input_file [small_text]
-log_dir a dirctory to save temp file [log/]
-cofile max length of word ngram [cooccur.bin]
-vocab_file output vocabulary [vocab.txt]
-temp_file temporary file of common occurrence chunk [temp.bin_]
-embd_file embedded file[wordvec.txt]
-vocab_size vocabulary size to train [0]
-max_size maximum size to keep in courpus [10000000]
-min_count minimum times [1]
-window the window size to get common occurrence [10]
-embed_size embedded size [80]
-epoch train epoch [1]
-threads max length of char ngram [40]
-memory_limit max length of char ngram [1]
-lr max length of char ngram [0.05]
-keep_case max length of char ngram [0]
-symmetric max length of char ngram [1]