Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
models
提交
cff7e36b
M
models
项目概览
PaddlePaddle
/
models
大约 1 年 前同步成功
通知
222
Star
6828
Fork
2962
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
602
列表
看板
标记
里程碑
合并请求
255
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
models
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
602
Issue
602
列表
看板
标记
里程碑
合并请求
255
合并请求
255
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
cff7e36b
编写于
1月 08, 2019
作者:
J
JiabinYang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refine readme and fix net conf bug
上级
bbf4aa7f
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
14 addition
and
8 deletion
+14
-8
fluid/PaddleRec/word2vec/README.md
fluid/PaddleRec/word2vec/README.md
+1
-1
fluid/PaddleRec/word2vec/network_conf.py
fluid/PaddleRec/word2vec/network_conf.py
+12
-6
fluid/PaddleRec/word2vec/train.py
fluid/PaddleRec/word2vec/train.py
+1
-1
未找到文件。
fluid/PaddleRec/word2vec/README.md
浏览文件 @
cff7e36b
...
...
@@ -29,7 +29,7 @@ This model implement a skip-gram model of word2vector.
Preprocess the training data to generate a word dict.
```
bash
python preprocess.py
--data_path
./data/1-billion-word-language-modeling-benchmark-r13output/training-monolingual.tokenized.shuffled
--dict_path
data/1-billion_dict
python preprocess.py
--data_path
./data/1-billion-word-language-modeling-benchmark-r13output/training-monolingual.tokenized.shuffled
--
is_local
--
dict_path
data/1-billion_dict
```
if you would like to use our supported third party vocab, please set --other_dict_path as the directory of where you
save the vocab you will use and set --with_other_dict flag on to using it.
...
...
fluid/PaddleRec/word2vec/network_conf.py
浏览文件 @
cff7e36b
...
...
@@ -95,8 +95,7 @@ def skip_gram_word2vec(dict_size,
capacity
=
64
,
feed_list
=
datas
,
name
=
'py_reader'
,
use_double_buffer
=
True
)
words
=
fluid
.
layers
.
read_file
(
py_reader
)
emb
=
fluid
.
layers
.
embedding
(
target_emb
=
fluid
.
layers
.
embedding
(
input
=
words
[
0
],
is_sparse
=
is_sparse
,
size
=
[
dict_size
,
embedding_size
],
...
...
@@ -104,16 +103,23 @@ def skip_gram_word2vec(dict_size,
name
=
'embeding'
,
initializer
=
fluid
.
initializer
.
Normal
(
scale
=
1
/
math
.
sqrt
(
dict_size
))))
context_emb
=
fluid
.
layers
.
embedding
(
input
=
words
[
1
],
is_sparse
=
is_sparse
,
size
=
[
dict_size
,
embedding_size
],
param_attr
=
fluid
.
ParamAttr
(
name
=
'embeding'
,
initializer
=
fluid
.
initializer
.
Normal
(
scale
=
1
/
math
.
sqrt
(
dict_size
))))
cost
,
cost_nce
,
cost_hs
=
None
,
None
,
None
if
with_nce
:
cost_nce
=
nce_layer
(
emb
,
words
[
1
],
embedding_size
,
dict_size
,
5
,
cost_nce
=
nce_layer
(
target_
emb
,
words
[
1
],
embedding_size
,
dict_size
,
5
,
"uniform"
,
word_frequencys
,
None
)
cost
=
cost_nce
if
with_hsigmoid
:
cost_hs
=
hsigmoid_layer
(
emb
,
words
[
1
],
words
[
2
],
words
[
3
],
dict_size
,
is_sparse
)
cost_hs
=
hsigmoid_layer
(
context_emb
,
words
[
0
],
words
[
2
],
words
[
3
]
,
dict_size
,
is_sparse
)
cost
=
cost_hs
if
with_nce
and
with_hsigmoid
:
cost
=
fluid
.
layers
.
elementwise_add
(
cost_nce
,
cost_hs
)
...
...
fluid/PaddleRec/word2vec/train.py
浏览文件 @
cff7e36b
...
...
@@ -278,7 +278,7 @@ def train(args):
optimizer
=
None
if
args
.
with_Adam
:
optimizer
=
fluid
.
optimizer
.
Adam
(
learning_rate
=
1e-4
)
optimizer
=
fluid
.
optimizer
.
Adam
(
learning_rate
=
1e-4
,
lazy_mode
=
True
)
else
:
optimizer
=
fluid
.
optimizer
.
SGD
(
learning_rate
=
1e-4
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录