Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
models
提交
6aabfcb5
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看板
提交
6aabfcb5
编写于
9月 20, 2018
作者:
L
luotao1
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
put clone(for_test=True) before optimization phase
上级
0f4edd78
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
9 addition
and
10 deletion
+9
-10
fluid/chinese_ner/train.py
fluid/chinese_ner/train.py
+2
-2
fluid/neural_machine_translation/transformer/train.py
fluid/neural_machine_translation/transformer/train.py
+7
-8
未找到文件。
fluid/chinese_ner/train.py
浏览文件 @
6aabfcb5
...
...
@@ -270,6 +270,8 @@ def main(args):
crf_decode
=
fluid
.
layers
.
crf_decoding
(
input
=
feature_out
,
param_attr
=
fluid
.
ParamAttr
(
name
=
'crfw'
))
inference_program
=
fluid
.
default_main_program
().
clone
(
for_test
=
True
)
sgd_optimizer
=
fluid
.
optimizer
.
SGD
(
learning_rate
=
1e-3
)
sgd_optimizer
.
minimize
(
avg_cost
)
...
...
@@ -282,8 +284,6 @@ def main(args):
chunk_evaluator
=
fluid
.
metrics
.
ChunkEvaluator
()
inference_program
=
fluid
.
default_main_program
().
clone
(
for_test
=
True
)
train_reader
=
paddle
.
batch
(
paddle
.
reader
.
shuffle
(
reader
.
file_reader
(
args
.
train_data_dir
),
buf_size
=
2000000
),
...
...
fluid/neural_machine_translation/transformer/train.py
浏览文件 @
6aabfcb5
...
...
@@ -257,11 +257,8 @@ def split_data(data, num_part):
]
def
test_context
(
t
rain_prog
m
,
avg_cost
,
train_exe
,
dev_count
,
data_input_names
,
def
test_context
(
t
est_progra
m
,
avg_cost
,
train_exe
,
dev_count
,
data_input_names
,
sum_cost
,
token_num
):
# Context to do validation.
test_program
=
train_progm
.
clone
(
for_test
=
True
)
val_data
=
reader
.
DataReader
(
src_vocab_fpath
=
args
.
src_vocab_fpath
,
trg_vocab_fpath
=
args
.
trg_vocab_fpath
,
...
...
@@ -315,7 +312,7 @@ def test_context(train_progm, avg_cost, train_exe, dev_count, data_input_names,
def
train_loop
(
exe
,
train_progm
,
dev_count
,
sum_cost
,
avg_cost
,
lr_scheduler
,
token_num
,
predict
):
token_num
,
predict
,
test_program
):
# Initialize the parameters.
if
TrainTaskConfig
.
ckpt_path
:
fluid
.
io
.
load_persistables
(
exe
,
TrainTaskConfig
.
ckpt_path
)
...
...
@@ -360,7 +357,7 @@ def train_loop(exe, train_progm, dev_count, sum_cost, avg_cost, lr_scheduler,
-
1
]
+
label_data_input_fields
if
args
.
val_file_pattern
is
not
None
:
test
=
test_context
(
t
rain_prog
m
,
avg_cost
,
train_exe
,
dev_count
,
test
=
test_context
(
t
est_progra
m
,
avg_cost
,
train_exe
,
dev_count
,
data_input_names
,
sum_cost
,
token_num
)
# the best cross-entropy value with label smoothing
...
...
@@ -484,6 +481,8 @@ def train(args):
TrainTaskConfig
.
warmup_steps
,
TrainTaskConfig
.
learning_rate
)
test_program
=
fluid
.
default_main_program
().
clone
(
for_test
=
True
)
if
args
.
local
:
optimizer
=
fluid
.
optimizer
.
Adam
(
learning_rate
=
lr_scheduler
.
learning_rate
,
...
...
@@ -511,7 +510,7 @@ def train(args):
print
(
"local start_up:"
)
train_loop
(
exe
,
fluid
.
default_main_program
(),
dev_count
,
sum_cost
,
avg_cost
,
lr_scheduler
,
token_num
,
predict
)
lr_scheduler
,
token_num
,
predict
,
test_program
)
else
:
port
=
os
.
getenv
(
"PADDLE_PORT"
,
"6174"
)
pserver_ips
=
os
.
getenv
(
"PADDLE_PSERVERS"
)
# ip,ip...
...
...
@@ -548,7 +547,7 @@ def train(args):
with
open
(
'trainer_prog.desc'
,
'w'
)
as
f
:
f
.
write
(
str
(
trainer_prog
))
train_loop
(
exe
,
trainer_prog
,
dev_count
,
sum_cost
,
avg_cost
,
lr_scheduler
,
token_num
,
predict
)
lr_scheduler
,
token_num
,
predict
,
test_program
)
else
:
print
(
"environment var TRAINER_ROLE should be TRAINER os PSERVER"
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录