Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
8fa09b82
P
Paddle
项目概览
BaiXuePrincess
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
8fa09b82
编写于
3月 04, 2017
作者:
Q
qiaolongfei
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add some comment for api_train_v2 of seqtoseq
上级
c5fb4fd4
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
12 addition
and
9 deletion
+12
-9
demo/seqToseq/api_train_v2.py
demo/seqToseq/api_train_v2.py
+12
-9
未找到文件。
demo/seqToseq/api_train_v2.py
浏览文件 @
8fa09b82
...
@@ -73,31 +73,34 @@ def main():
...
@@ -73,31 +73,34 @@ def main():
cost
=
seqToseq_net_v2
(
source_dict_dim
,
target_dict_dim
)
cost
=
seqToseq_net_v2
(
source_dict_dim
,
target_dict_dim
)
parameters
=
paddle
.
parameters
.
create
(
cost
)
parameters
=
paddle
.
parameters
.
create
(
cost
)
# define optimize method and trainer
optimizer
=
paddle
.
optimizer
.
Adam
(
learning_rate
=
1e-4
)
optimizer
=
paddle
.
optimizer
.
Adam
(
learning_rate
=
1e-4
)
def
event_handler
(
event
):
if
isinstance
(
event
,
paddle
.
event
.
EndIteration
):
if
event
.
batch_id
%
10
==
0
:
print
"Pass %d, Batch %d, Cost %f, %s"
%
(
event
.
pass_id
,
event
.
batch_id
,
event
.
cost
,
event
.
metrics
)
trainer
=
paddle
.
trainer
.
SGD
(
cost
=
cost
,
trainer
=
paddle
.
trainer
.
SGD
(
cost
=
cost
,
parameters
=
parameters
,
parameters
=
parameters
,
update_equation
=
optimizer
)
update_equation
=
optimizer
)
# define data reader
reader_dict
=
{
reader_dict
=
{
'source_language_word'
:
0
,
'source_language_word'
:
0
,
'target_language_word'
:
1
,
'target_language_word'
:
1
,
'target_language_next_word'
:
2
'target_language_next_word'
:
2
}
}
trn
_reader
=
paddle
.
reader
.
batched
(
wmt14
_reader
=
paddle
.
reader
.
batched
(
paddle
.
reader
.
shuffle
(
paddle
.
reader
.
shuffle
(
train_reader
(
"data/pre-wmt14/train/train"
),
buf_size
=
8192
),
train_reader
(
"data/pre-wmt14/train/train"
),
buf_size
=
8192
),
batch_size
=
5
)
batch_size
=
5
)
# define event_handler callback
def
event_handler
(
event
):
if
isinstance
(
event
,
paddle
.
event
.
EndIteration
):
if
event
.
batch_id
%
10
==
0
:
print
"Pass %d, Batch %d, Cost %f, %s"
%
(
event
.
pass_id
,
event
.
batch_id
,
event
.
cost
,
event
.
metrics
)
# start to train
trainer
.
train
(
trainer
.
train
(
reader
=
trn
_reader
,
reader
=
wmt14
_reader
,
event_handler
=
event_handler
,
event_handler
=
event_handler
,
num_passes
=
10000
,
num_passes
=
10000
,
reader_dict
=
reader_dict
)
reader_dict
=
reader_dict
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录