Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
models
提交
25571110
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看板
提交
25571110
编写于
11月 26, 2019
作者:
H
hysunflower
提交者:
Jinhua Liang
11月 26, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add for bert models (#3976)
* add_for_bert_models * update add_for_bert_models * update for add_for_bert_models
上级
2e4465c6
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
22 addition
and
0 deletion
+22
-0
PaddleNLP/PaddleLARK/BERT/run_classifier.py
PaddleNLP/PaddleLARK/BERT/run_classifier.py
+22
-0
未找到文件。
PaddleNLP/PaddleLARK/BERT/run_classifier.py
浏览文件 @
25571110
...
...
@@ -32,6 +32,7 @@ import multiprocessing
import
paddle
import
paddle.fluid
as
fluid
from
paddle.fluid
import
profiler
import
reader.cls
as
reader
from
model.bert
import
BertConfig
...
...
@@ -93,6 +94,12 @@ data_g.add_arg("do_lower_case", bool, True,
data_g
.
add_arg
(
"random_seed"
,
int
,
0
,
"Random seed."
)
run_type_g
=
ArgumentGroup
(
parser
,
"run_type"
,
"running type options."
)
# NOTE:profiler args, used for benchmark
run_type_g
.
add_arg
(
"profiler_path"
,
str
,
'./'
,
"the profiler output file path. (used for benchmark)"
)
run_type_g
.
add_arg
(
"is_profiler"
,
int
,
0
,
"the profiler switch. (used for benchmark)"
)
run_type_g
.
add_arg
(
"max_iter"
,
int
,
0
,
"the max batch nums to train. (used for benchmark)"
)
run_type_g
.
add_arg
(
"use_cuda"
,
bool
,
True
,
"If set, use GPU for training."
)
run_type_g
.
add_arg
(
"use_fast_executor"
,
bool
,
False
,
"If set, use fast parallel executor (in experiment)."
)
run_type_g
.
add_arg
(
"shuffle"
,
bool
,
True
,
""
)
...
...
@@ -317,9 +324,17 @@ def main(args):
time_begin
=
time
.
time
()
throughput
=
[]
ce_info
=
[]
total_batch_num
=
0
# used for benchmark
while
True
:
try
:
steps
+=
1
total_batch_num
+=
1
# used for benchmark
if
args
.
max_iter
and
total_batch_num
==
args
.
max_iter
:
# used for benchmark
return
if
steps
%
args
.
skip_steps
==
0
:
if
args
.
use_fp16
:
fetch_list
=
[
loss
.
name
,
accuracy
.
name
,
scheduled_lr
.
name
,
num_seqs
.
name
,
loss_scaling
.
name
]
...
...
@@ -353,6 +368,13 @@ def main(args):
time_end
=
time
.
time
()
used_time
=
time_end
-
time_begin
# profiler tools
if
args
.
is_profiler
and
current_epoch
==
0
and
steps
==
args
.
skip_steps
:
profiler
.
start_profiler
(
"All"
)
elif
args
.
is_profiler
and
current_epoch
==
0
and
steps
==
args
.
skip_steps
*
2
:
profiler
.
stop_profiler
(
"total"
,
args
.
profiler_path
)
return
log_record
=
"epoch: {}, progress: {}/{}, step: {}, ave loss: {}, ave acc: {}"
.
format
(
current_epoch
,
current_example
,
num_train_examples
,
steps
,
np
.
sum
(
total_cost
)
/
np
.
sum
(
total_num_seqs
),
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录