官方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. python 杂项

        Python/JS/    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ...

  2. .NET开源Protobuf-net组件葵花手册

    一.前言 我们都知道 protobuf是由Google开发的一款与平台无关,语言无关,可扩展的序列化结构数据格式,可用做数据存储格式, 通信协议 ! 在前面<.NET开源Protobuf-net ...

  3. python测试开发django-50.jquery发送ajax请求(get)

    前言 有时候,我们希望点击页面上的某个按钮后,不刷新整个页面,给后台发送一个请求过去,请求到数据后填充到html上,这意味着可以在不重新加载整个网页的情况下,对网页的某部分进行更新.Ajax可以完美的 ...

  4. SharePoint 上传文档提示别人迁出

    前言 我们在使用SharePoint文档库的时候,经常会遇到文档被别人迁出,自己无法修改的情况.这时候,我们最好的办法就是找到那个迁出的人,怼他!如果,他已经离职了,我们无法找到,那么,就请继续往瞎看 ...

  5. ios之animateWithDuration的坑

    [UIView animateWithDuration:<#(NSTimeInterval)#> delay:<#(NSTimeInterval)#> options:< ...

  6. 怎样在 Ubuntu 16.04 强制 APT 包管理器使用 IPv4 | Linux 中国

    版权声明:本文为博主原创文章.未经博主同意不得转载. https://blog.csdn.net/F8qG7f9YD02Pe/article/details/82879401 https://mmbi ...

  7. SpringBoot 定时任务不能同时运行的问题

    使用Spring Task可以非常方便的进行定时任务,但是默认只能有一个定时任务在执行.如何改变这种状况呢? 在定时任务方法上添加@Async注解即可. @Scheduled(cron = " ...

  8. 如何做好Puppet Modules管理

    如何做好Puppet Modules管理 不同于其他的Openstack项目,puppet modules是一个数量庞大的存在.以我们当前在使用中的puppet modules为例,就已经多达96个( ...

  9. centos exfat格式U盘不支持问题

    centos exfat格式U盘不支持问题 1. 下载fuse-exfat-1.3.0-1.el7.x86_64.rpm 2. 终端安装 rpm  -ivh fuse-exfat-1.3.0-1.el ...

  10. grid - 通过网格区域命名和定位网格项目

    1.像网格线名称一样,网格区域的名称也可以使用grid-template-areas属性来命名.引用网格区域名称也可以设置网格项目位置. 设置网格区域的名称应该放置在单引号或双引号内,每个名称由一个空 ...