官方word2vec的github下载地址:https://github.com/svn2github/word2vec

环境,linux-ubuntu-14.04LST,安装好git, gcc版本4.8.4

linux下的安装方式:

% git clone https://github.com/svn2github/word2vec.git

% cd word2vec

% make

命令解析:

-train <file>
  Use text data from <file> to train the model
-output <file>
  Use <file> to save the resulting word vectors / word clusters
-size <int>
  Set size of word vectors; default is 100
-window <int>
  Set max skip length between words; default is 5
-sample <float>
  Set threshold for occurrence of words. Those that appear with higher frequency in the training data
  will be randomly down-sampled; default is 1e-3, useful range is (0, 1e-5)
-hs <int>
  Use Hierarchical Softmax; default is 0 (not used)
-negative <int>
  Number of negative examples; default is 5, common values are 3 - 10 (0 = not used)
-threads <int>
  Use <int> threads (default 12)
-iter <int>
  Run more training iterations (default 5)
-min-count <int>
  This will discard words that appear less than <int> times; default is 5
-alpha <float>
  Set the starting learning rate; default is 0.025 for skip-gram and 0.05 for CBOW
-classes <int>
  Output word classes rather than word vectors; default number of classes is 0 (vectors are written)
-debug <int>
  Set the debug mode (default = 2 = more info during training)
-binary <int>
  Save the resulting vectors in binary moded; default is 0 (off)
-save-vocab <file>
  The vocabulary will be saved to <file>
-read-vocab <file>
  The vocabulary will be read from <file>, not constructed from the training data
-cbow <int>
  Use the continuous bag of words model; default is 1 (use 0 for skip-gram model)

之后准备训练预料就可以了,将分词后的文件拼成一行,训练即可,

./word2vec -train fudan_corpus_final -output fudan_100_skip.bin -cbow 0 -size 100 -windows 10 -negative 5 -hs 0 -binary 1 -sample 1e-4 -threads 20 -iter 15

对于生成 “fudan_100_skip.bin” 文件,可以用gensim 转换为txt明文形式:

from gensim.models import word2vec

model = word2vec.Word2Vec.load_word2vec_format('path/to/GoogleNews-vectors-negative300.bin', binary=True)
model.save_word2vec_format('path/to/GoogleNews-vectors-negative300.txt', binary=False)

注意:windows下需要先 切换到 gensim的环境(activate gensim),然后再执行

但是以上关于gensim读取的在我这有问题,因此采用原生方法:参考自http://stackoverflow.com/questions/27324292/convert-word2vec-bin-file-to-text
将以上链接中的c代码copy下来,取名readbin.c
编译readbin.c文件时由于涉及math库,因此命令为:
% gcc -o readbin readbin.c -lm
之后执行将bin文件转换为txt文件的操作即可:
% ./readbin fudan_100_skip.bin fudan_100.txt

word2vec:基本的安装及使用简介的更多相关文章

  1. MinGW安装与使用简介

    MinGW 安装与使用简介 安装方法:其实很简单,如下: Step one: 到这里下载 MinGW, 网速慢的话可能打不开, 是个外国网站 (上面的网站镜像可能 出了点问题 , 有的东西下载下来却不 ...

  2. Spotlight on Mysql在Windows平台下的安装及使用简介

    Spotlight on Mysql在Windows平台下的安装及使用简介   by:授客 QQ:1033553122 1.   测试环境 Win7 64位 mysql-connector-odbc- ...

  3. Centos7 Cacti-0.8.8g安装及SNMP简介

    在官网可以看到关于cacti的下载说明http://www.cacti.net/download_cacti.php Download Cacti The latest stable version ...

  4. Nginx安装及配置简介

    前言 Nginx是一款轻量级的Web 服务器/反向代理服务器及电子邮件(IMAP/POP3)代理服务器,并在一个BSD-like 协议下发行.由俄罗斯的程序设计师Igor Sysoev所开发,供俄国大 ...

  5. redis安装及数据类型简介(string、list、set、sorted_set、hash)

    一:简介: redis国内最大的案例--->新浪微博 memcache:是key-value数据库 数据类型:只支持key value数据 过期策略:支持 持久化:不支持(可以通过三方程序) 主 ...

  6. 【嵌入式开发】 Linux Kernel 下载 配置 编译 安装 及 驱动简介

    作者 : 韩曙亮 转载请出名出处 : http://blog.csdn.net/shulianghan/article/details/38636827 一. Linux 内核简介 1. 内核功能简介 ...

  7. PM2的安装和使用简介

    一.简介 PM2是node进程管理工具,可以利用它来简化很多node应用管理的繁琐任务,如性能监控.自动重启.负载均衡等,而且使用非常简单. 二.前期必备 node 环境 npm 三.安装 全局安装 ...

  8. OpenCL学习笔记(三):OpenCL安装,编程简介与helloworld

    欢迎转载,转载请注明:本文出自Bin的专栏blog.csdn.net/xbinworld. 技术交流QQ群:433250724,欢迎对算法.技术.应用感兴趣的同学加入. OpenCL安装 安装我不打算 ...

  9. nginx之 nginx-1.9.7 编译安装、理论简介

    nginx是一个web网站常用的高性能http和反向代理服务器,其具有较好的并发能力,被网易.百度.腾讯.新浪等网站广泛使用. 一. 理论简介 1.首先弄清楚正向代理和反向代理 正向代理:代理客户端, ...

随机推荐

  1. SharePoint JavaScript 更新用户和组字段

    前言 最近,需要更新列表字段,字段的类型是用户和组,so写了这么一段代码 function updateUserField(){ var ctx = new SP.ClientContext.get_ ...

  2. Node + Selenium使用小结

    可参考网上的步骤进行操作.例如这篇文章:https://wangheng3751.github.io/2018/01/17/selenium/ 1.安装Node.js,去官网下载最新版本的Node.j ...

  3. 怎样让两个DIV在同一水平线上面显示

    css定义第二个div. float:right或者left. margin-top:0px 确保第二个DIV的宽度.如果宽度宽的话,会自动到下方的.

  4. Javascript 面向对象的编程思想

    面向对象,首先得有类的概念,没有类造不出来对象,,Javascript把函数名看成类. 其次分为不同结构层,如三层架构.MVC.MVVM. 本文根据实际项目演练,分为几个适用的结构层,如果项目不大一般 ...

  5. angular 2 - 002 - 基本概念和使用

    service的注入, 注入的是service的单一实例

  6. 数据分析:基于Python的自定义文件格式转换系统

    *:first-child { margin-top: 0 !important; } body>*:last-child { margin-bottom: 0 !important; } /* ...

  7. Oracle 11g透明网关连接Sqlserver

    Oracle 11g透明网关连接Sqlserver oracle 透明网关是oracle连接异构数据库提供的一种技术.通过Gateway,可以在Oracle里透明的访问其他不同的数据库,如SQL Se ...

  8. QGIS Server使用记录

    目录 0. 简述 1. 下载QGIS桌面64位版本 2. 下载安装QGIS Server程序 3. 下载安装Apache服务器 4.使用及问题处理 0. 简述 关于QGIS Server相关的文档很少 ...

  9. [转]numpy 100道练习题

    100 numpy exercise 翻译:YingJoy 网址: https://www.yingjoy.cn/ 来源:https://github.com/rougier/numpy-100 Nu ...

  10. --defaults-file 不能用?

    今天在测试mysql多实例时发现mysqld_safe --user --defaults-file 怎么都无法启动,后来发现是必须按顺序,先写--defaults-file才可以. mysqld_s ...