资源简介
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++) {
fscanf(f “%s%c“ &vocab[b * max_w] &ch);
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“)) || feof(stdin)) {
if (TCN == 0) TCN = 1;
if (QID != 0) {
printf(“ACCURACY TOP1: %.2f %%
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 5200 2014-08-15 12:04 word2vec\compute-accuracy.c
文件 636 2014-08-15 12:05 word2vec\demo-analogy.sh
文件 354 2014-08-15 12:07 word2vec\demo-classes.sh
文件 845 2014-08-15 12:12 word2vec\demo-phrase-accuracy.sh
文件 367 2014-08-15 12:12 word2vec\demo-phrases.sh
文件 267 2014-08-15 12:13 word2vec\demo-word.sh
文件 410 2014-08-15 12:13 word2vec\demo-word-accuracy.sh
文件 4515 2014-08-15 12:14 word2vec\distance.c
文件 11524 2014-08-15 11:34 word2vec\LICENSE
文件 715 2014-08-15 12:14 word2vec\makefile
文件 171430 2014-08-15 12:14 word2vec\questions-phrases.txt
文件 623511 2014-08-15 12:15 word2vec\questions-words.txt
文件 1226 2014-08-15 12:01 word2vec\README
文件 9676 2014-08-15 12:16 word2vec\word2phrase.c
文件 25975 2014-08-15 12:16 word2vec\word2vec.c
文件 4624 2014-08-15 12:15 word2vec\word-analogy.c
- 上一篇:搜狗1.4G 新闻集
- 下一篇:钟馗之眼搜索辅助工具.exe
相关资源
- 搜狗1.4G 新闻集
- 安卓视频播放器源码
- 三网快速充值话费通道源码.zip
- 23种设计模式视频+源码.txt
- 经典教程《Digital Watermarking and Stegan
- .net 图片转字符画,可选择数字字符画
- 野外生存游戏源码Ultimate Survival_v0.1
- AD2S1210源码
- QQ飞车卡车源码
- 传智博客汤阳光最新企业oa视频+源码
- 安卓截屏小工具源码
- Qt点线效果源码
- 易语言伪造ip访问源码(全注释)
- LDC1000 stm32源码
- 2048游戏源码
- springboot源码解析视频
- QQ会员业务源码_带支付宝转账功能
- 驱动级鼠标键盘模拟含最新WinIo资源及
- 淘宝上的微信小程序和小游戏视频教
- QT编写的Socket工具,TCP 以及 UDP 可建立
- JS打地鼠小游戏源码
- 微机电子琴汇编源码+详细说明
- 电信物联网开发者平台北向API_DEMO源码
- 基于stm32碰撞球游戏仿真设计程序源码
- uwb多基站多信标定位stm32源码
- uwb定位stm32源码
- 易语言检测更新源码密码qaz123.
- 四小人源码
- 改进的Booth算法单精度浮点乘法器源码
- 易语言源码QQ批量登陆
评论
共有 条评论