资源简介
用来得到TXT文本中词语的相关性的深度学习模型,需要分词,text8为样例,运行脚本可以直接开始训练。最后得到.bin模型
代码片段和文件信息
// 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 2018-05-27 06:57 word2vec-master\
文件 412 2018-05-01 05:52 word2vec-master\demo-word-accuracy.sh
文件 13712 2018-04-30 07:31 word2vec-master\compute-accuracy
文件 21728 2018-04-30 07:31 word2vec-master\word-analogy
文件 21776 2018-04-30 07:31 word2vec-master\distance
文件 23056 2018-04-30 07:31 word2vec-master\word2phrase
文件 26184 2015-01-30 19:30 word2vec-master\word2vec.c
文件 9386 2015-01-30 19:30 word2vec-master\word2phrase.c
文件 4664 2015-01-30 19:30 word2vec-master\word-analogy.c
文件 603955 2015-01-30 19:30 word2vec-master\questions-words.txt
文件 168209 2015-01-30 19:30 word2vec-master\questions-phrases.txt
文件 718 2015-01-30 19:30 word2vec-master\makefile
文件 4557 2015-01-30 19:30 word2vec-master\distance.c
文件 5126 2015-01-30 19:30 word2vec-master\demo-train-big-model-v1.sh
文件 853 2015-01-30 19:30 word2vec-master\demo-phrases.sh
文件 885 2015-01-30 19:30 word2vec-master\demo-phrase-accuracy.sh
文件 631 2015-01-30 19:30 word2vec-master\demo-analogy.sh
文件 5241 2015-01-30 19:30 word2vec-master\compute-accuracy.c
文件 1209 2015-01-30 19:30 word2vec-master\README.txt
文件 100000000 2009-07-23 17:36 word2vec-master\text8
文件 53328 2018-04-30 07:31 word2vec-master\word2vec
文件 272 2018-05-27 06:56 word2vec-master\demo-word.sh
文件 11358 2015-01-30 19:30 word2vec-master\LICENSE
文件 356 2018-05-01 05:50 word2vec-master\demo-classes.sh
- 上一篇:查表计算sin值
- 下一篇:理正岩土v6.0 破解版
相关资源
- LabelImg 图像标注工具 深度学习必备工
- 深度学习 AI圣经 deep learning-张志华-
- 深度学习相关资料
- 网易云吴恩达深度学习工程师微专业
- 深度学习基础(FundamentalsofDeepLearnin
- 《深度学习之TensorFlow:入门、原理与
- AI圣经深度学习.rar
- 《生成式深度学习》Generative Deep Lea
- 深度学习 花书
- 深度学习中文-花书-无水印版
- sEMG基于肌电信号的深度学习数据集
- 深度学习课程_吴恩达PPT汇总
- 机器学习入门:Softmax
- 深度学习花书高清中文版和英文原版
- 瑕疵检测数据集
- 深度学习:21天实战Caffe 高清完整版
- 强化学习精要 核心算法与TensorFlow实现
- 机器学习,概率模型和深度学习的讲
- 《Tensorflow:实战Google深度学习框架》
- 基于深度学习的图像去雨
- tensorflow深度学习三部曲.rar
- deeplearning.ai_notebook.zip
- 吴恩达老师deeplearning.ai-全部课件
- 深度学习入门之PyTorch.廖星宇.zip
- 深度学习入门之PyTorch-廖星宇高清pd
- 深度学习入门之PyTorch.廖星宇.pdf
- 深度学习:21天实战Caffe-真正清晰版本
- keras人脸表情识别.rar
- 国科大深度学习课程课件
- cifar10经典数据集
评论
共有 条评论