手套蟒蛇绑定

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]

参考值

  • GloVe
  • Jeffrey Pennington,Richard Socher和Christopher D.Manning。2014年。手套:单词表示的全局向量。
  • GloVe-cpp

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
Java例外。Lang.Stringindexoutofboundsexception索引超出范围(0)   java Spring引导Freemarker从2.2.0升级失败   重构Java反模式名称?包含对象的对象包含。。。等   用java处理JDBC可能出现的死锁的最佳方法   java无法访问主线程上的数据库,因为它可能会在很长一段时间内锁定UI   java如何将固定大小的画布包装在边框窗格中的滚动窗格居中?   java解析xsd文件后得到空结果   在html页面中表示XML文件的java   socketjava对象流   sql Java越界异常数据库   JavaJBoss7.1.1不会在Mavericks上启动   Twincat ADS事件驱动读取在一段时间后停止工作(Java)   java MyBatis使用生成的ID插入所有   Mojave上缺少MacOS Java控制面板   JavaGuice:如果多次注入相同的依赖项,是否注入了该依赖项的相同实例?