资源简介
google word2vec开源项目(源码),由于在国内直接访问不到,所以上传到这里,供大家使用。如果可以,给我博客点个赞 *-*

代码片段和文件信息
// Copyright 2013 Google Inc. All Rights Reserved.
//
// Licensed under the Apache License Version 2.0 (the “License“);
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing software
// distributed under the License is distributed on an “AS IS“ BASIS
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include
#include
#include
#include
#include
#include
const long long max_size = 2000; // max length of strings
const long long N = 1; // number of closest words
const long long max_w = 50; // max length of vocabulary entries
int main(int argc char **argv)
{
FILE *f;
char st1[max_size] st2[max_size] st3[max_size] st4[max_size] bestw[N][max_size] file_name[max_size] ch;
float dist len bestd[N] vec[max_size];
long long words size a b c d b1 b2 b3 threshold = 0;
float *M;
char *vocab;
int TCN CCN = 0 TACN = 0 CACN = 0 SECN = 0 SYCN = 0 SEAC = 0 SYAC = 0 QID = 0 TQ = 0 TQS = 0;
if (argc < 2) {
printf(“Usage: ./compute-accuracy \nwhere FILE contains word projections and threshold is used to reduce vocabulary of the model for fast approximate evaluation (0 = off otherwise typical value is 30000)\n“);
return 0;
}
strcpy(file_name argv[1]);
if (argc > 2) threshold = atoi(argv[2]);
f = fopen(file_name “rb“);
if (f == NULL) {
printf(“Input file not found\n“);
return -1;
}
fscanf(f “%lld“ &words);
if (threshold) if (words > threshold) words = threshold;
fscanf(f “%lld“ &size);
vocab = (char *)malloc(words * max_w * sizeof(char));
M = (float *)malloc(words * size * sizeof(float));
if (M == NULL) {
printf(“Cannot allocate memory: %lld MB\n“ words * size * sizeof(float) / 1048576);
return -1;
}
for (b = 0; b < words; b++) {
a = 0;
while (1) {
vocab[b * max_w + a] = fgetc(f);
if (feof(f) || (vocab[b * max_w + a] == ‘ ‘)) break;
if ((a < max_w) && (vocab[b * max_w + a] != ‘\n‘)) a++;
}
vocab[b * max_w + a] = 0;
for (a = 0; a < max_w; a++) vocab[b * max_w + a] = toupper(vocab[b * max_w + a]);
for (a = 0; a < size; a++) fread(&M[a + b * size] sizeof(float) 1 f);
len = 0;
for (a = 0; a < size; a++) len += M[a + b * size] * M[a + b * size];
len = sqrt(len);
for (a = 0; a < size; a++) M[a + b * size] /= len;
}
fclose(f);
TCN = 0;
while (1) {
for (a = 0; a < N; a++) bestd[a] = 0;
for (a = 0; a < N; a++) bestw[a][0] = 0;
scanf(“%s“ st1);
for (a = 0; a < strlen(st1); a++) st1[a] = toupper(st1[a]);
if ((!strcmp(st1 “:“)) || (!strcmp(st1 “EXIT“)) || f
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2016-03-18 04:03 word2vec\
目录 0 2016-03-18 04:03 word2vec\.svn\
文件 57 2016-03-18 04:03 word2vec\.svn\all-wcprops
目录 0 2016-03-18 04:03 word2vec\.svn\tmp\
目录 0 2016-03-18 04:03 word2vec\.svn\tmp\prop-ba
目录 0 2016-03-18 04:03 word2vec\.svn\tmp\props\
目录 0 2016-03-18 04:03 word2vec\.svn\tmp\text-ba
目录 0 2016-03-18 04:03 word2vec\.svn\prop-ba
目录 0 2016-03-18 04:03 word2vec\.svn\props\
目录 0 2016-03-18 04:03 word2vec\.svn\text-ba
文件 189 2016-03-18 04:03 word2vec\.svn\entries
目录 0 2016-03-18 04:03 word2vec\trunk\
文件 853 2016-03-18 04:03 word2vec\trunk\demo-phrases.sh
文件 272 2016-03-18 04:03 word2vec\trunk\demo-word.sh
文件 168209 2016-03-18 04:03 word2vec\trunk\questions-phrases.txt
文件 414 2016-03-18 04:03 word2vec\trunk\demo-word-accuracy.sh
文件 1209 2016-03-18 04:03 word2vec\trunk\README.txt
文件 718 2016-03-18 04:03 word2vec\trunk\makefile
文件 9386 2016-03-18 04:03 word2vec\trunk\word2phrase.c
文件 5241 2016-03-18 04:03 word2vec\trunk\compute-accuracy.c
目录 0 2016-03-18 04:03 word2vec\trunk\.svn\
文件 1680 2016-03-18 04:03 word2vec\trunk\.svn\all-wcprops
目录 0 2016-03-18 04:03 word2vec\trunk\.svn\tmp\
目录 0 2016-03-18 04:03 word2vec\trunk\.svn\tmp\prop-ba
目录 0 2016-03-18 04:03 word2vec\trunk\.svn\tmp\props\
目录 0 2016-03-18 04:03 word2vec\trunk\.svn\tmp\text-ba
目录 0 2016-03-18 04:03 word2vec\trunk\.svn\prop-ba
文件 30 2016-03-18 04:03 word2vec\trunk\.svn\prop-ba
目录 0 2016-03-18 04:03 word2vec\trunk\.svn\props\
目录 0 2016-03-18 04:03 word2vec\trunk\.svn\text-ba
文件 9386 2016-03-18 04:03 word2vec\trunk\.svn\text-ba
............此处省略26个文件信息
- 上一篇:webgis面试题开源gis
- 下一篇:内蒙古风速50425.zip
相关资源
- 广联达6.0写锁包,2020年11月最新
- 机器学习个人笔记完整版v5.2-A4打印版
- 深度学习卷积神经网络可检测和分类
- GAN对抗式生成网络的应用:从图片上
- [en]深度学习[Deep Learning: Adaptive Compu
- 李宏毅-机器学习(视频2017完整)
- 吴恩达深度学习第一课第四周作业及
- 机器学习深度学习 PPT
- 麻省理工:深度学习介绍PPT-1
- Wikipedia机器学习迷你电子书之四《D
- 深度学习在遥感中的应用综述
- 深度学习数据集标注
- 深度学习算法实践源码-吴岸城
- 李宏毅深度学习ppt
- SSD目标检测算法论文-英文原版
- 台湾李宏毅教授深度学习讲义 pdf
- 基于深度学习实现人脸识别包含模型
- 深度学习与PyTorch-代码和PPT.zip
- 测试工程源码1(一种基于深度学习的
- 深度学习: MNIST的数据集
- 《深度学习》 高清版本中文PDFIan Go
- 今日头条38万条新闻数据标题
- 维基百科中文语料已分词
- 深度学习算法论文
- TensorFlow Machine Learning Cookbook+无码高清
- Hands-On Machine Learning with Scikit-Learn an
- Neural Networks:Tricks of the Trade+无码高清
- 基于深度学习的图像超分辨率算法论
- 人工智能初步学习总结
- 迁移学习简明手册
评论
共有 条评论