word2vec核心代码注释.pdf

  1. 1、本文档共14页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
word2vec核心代码注释

建议对照word2vec.c 看注释,标红部分为中文注释以及相应代码,added by lijiawei // 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 // // /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. #define MAX_STRING 100 #define EXP_TABLE_SIZE 1000 #define MAX_EXP 6 #define MAX_SENTENCE_LENGTH 1000 #define MAX_CODE_LENGTH 40 const int vocab_hash_size = // Maximum 30 * 0.7 = 21M words in the vocabulary typedef float real; // Precision of float numbers //@brief 输入文件中每个基本词的结构体 //cn,该本词出现的数量 //point,哈弗曼树中,从root 节点到该基本词的路径,指针数组,存放的是每个父节点在vocabulary 中的索引 //word,基本词字面 //code,该基本词的哈弗曼码 //codelen ,该基本词的哈弗曼码的长度 struct vocab_word { long long cn; int *point; char *word, *code, codelen; }; char train_file[MAX_STRING], output_file[MAX_STRING]; char save_vocab_file[MAX_STRING], read_vocab_file[MAX_STRING]; //@brief 输入文件中每个基本词的结构体数组,即paper 中的vocabulary struct vocab_word *vocab; int binary = 0, cbow = 0, debug_mode = 2, window = 5, min_count = 5, num_threads = 1, min_reduce = 1; //@brief 该数组存文件中基本词的字面的hash 码,和基本词在vocab_word 数组中的位置 //其中基本词的字面的hash 码作为该数组的下标, int *vocab_hash; long long vocab_max_size = 1000, vocab_size = 0, layer1_size = 100; long long train_words = 0, word_count_actual = 0, file_size = 0, classes = 0; real alpha = 0.025, starting_alpha, sample = 0; //@brief //syn0 即基本词的input feature vector 矩阵,当然cbow 是把上下文的input feature vector 相加 //syn1 实际上是文章中的Wx 的W 矩阵

文档评论(0)

yan698698 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档