Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleDetection
提交
e60d94b3
P
PaddleDetection
项目概览
PaddlePaddle
/
PaddleDetection
1 年多 前同步成功
通知
696
Star
11112
Fork
2696
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
184
列表
看板
标记
里程碑
合并请求
40
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleDetection
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
184
Issue
184
列表
看板
标记
里程碑
合并请求
40
合并请求
40
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
e60d94b3
编写于
3月 03, 2017
作者:
Q
qiaolongfei
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
correct data_type
上级
495861f5
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
9 addition
and
9 deletion
+9
-9
demo/seqToseq/api_train_v2.py
demo/seqToseq/api_train_v2.py
+6
-6
demo/seqToseq/seqToseq_net_v2.py
demo/seqToseq/seqToseq_net_v2.py
+3
-3
未找到文件。
demo/seqToseq/api_train_v2.py
浏览文件 @
e60d94b3
...
...
@@ -4,7 +4,8 @@ import paddle.v2 as paddle
from
seqToseq_net_v2
import
seqToseq_net_v2
### Data Definiation
# Data Definiation.
# TODO:This code should be merged to dataset package.
data_dir
=
"./data/pre-wmt14"
src_lang_dict
=
os
.
path
.
join
(
data_dir
,
'src.dict'
)
trg_lang_dict
=
os
.
path
.
join
(
data_dir
,
'trg.dict'
)
...
...
@@ -68,15 +69,14 @@ def train_reader(file_name):
def
main
():
paddle
.
init
(
use_gpu
=
False
,
trainer_count
=
1
)
# reader = train_reader("data/pre-wmt14/train/train")
# define network topology
cost
=
seqToseq_net_v2
(
source_dict_dim
,
target_dict_dim
)
parameters
=
paddle
.
parameters
.
create
(
cost
)
optimizer
=
paddle
.
optimizer
.
Adam
(
batch_size
=
50
,
learning_rate
=
5
e-4
)
optimizer
=
paddle
.
optimizer
.
Adam
(
learning_rate
=
1
e-4
)
def
event_handler
(
event
):
if
isinstance
(
event
,
paddle
.
event
.
EndIteration
):
if
event
.
batch_id
%
10
0
==
0
:
if
event
.
batch_id
%
10
==
0
:
print
"Pass %d, Batch %d, Cost %f, %s"
%
(
event
.
pass_id
,
event
.
batch_id
,
event
.
cost
,
event
.
metrics
)
...
...
@@ -93,12 +93,12 @@ def main():
trn_reader
=
paddle
.
reader
.
batched
(
paddle
.
reader
.
shuffle
(
train_reader
(
"data/pre-wmt14/train/train"
),
buf_size
=
8192
),
batch_size
=
10
)
batch_size
=
10
000
)
trainer
.
train
(
reader
=
trn_reader
,
event_handler
=
event_handler
,
num_passes
=
10
000
,
num_passes
=
10
,
reader_dict
=
reader_dict
)
...
...
demo/seqToseq/seqToseq_net_v2.py
浏览文件 @
e60d94b3
...
...
@@ -14,7 +14,7 @@ def seqToseq_net_v2(source_dict_dim, target_dict_dim):
#### Encoder
src_word_id
=
layer
.
data
(
name
=
'source_language_word'
,
type
=
data_type
.
dense_vector
(
source_dict_dim
))
type
=
data_type
.
integer_value_sequence
(
source_dict_dim
))
src_embedding
=
layer
.
embedding
(
input
=
src_word_id
,
size
=
word_vector_dim
,
...
...
@@ -67,7 +67,7 @@ def seqToseq_net_v2(source_dict_dim, target_dict_dim):
trg_embedding
=
layer
.
embedding
(
input
=
layer
.
data
(
name
=
'target_language_word'
,
type
=
data_type
.
dense_vector
(
target_dict_dim
)),
type
=
data_type
.
integer_value_sequence
(
target_dict_dim
)),
size
=
word_vector_dim
,
param_attr
=
attr
.
ParamAttr
(
name
=
'_target_language_embedding'
))
group_inputs
.
append
(
trg_embedding
)
...
...
@@ -84,7 +84,7 @@ def seqToseq_net_v2(source_dict_dim, target_dict_dim):
lbl
=
layer
.
data
(
name
=
'target_language_next_word'
,
type
=
data_type
.
dense_vector
(
target_dict_dim
))
type
=
data_type
.
integer_value_sequence
(
target_dict_dim
))
cost
=
layer
.
classification_cost
(
input
=
decoder
,
label
=
lbl
)
return
cost
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录