Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
magicwindyyd
mindspore
提交
9a1b81df
M
mindspore
项目概览
magicwindyyd
/
mindspore
与 Fork 源项目一致
Fork自
MindSpore / mindspore
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
mindspore
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
9a1b81df
编写于
8月 10, 2020
作者:
M
mindspore-ci-bot
提交者:
Gitee
8月 10, 2020
浏览文件
操作
浏览文件
下载
差异文件
!4186 bert script bugfix
Merge pull request !4186 from yoonlee666/bugfix
上级
ce2e8839
a5ac2427
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
17 addition
and
11 deletion
+17
-11
model_zoo/official/nlp/bert/run_classifier.py
model_zoo/official/nlp/bert/run_classifier.py
+4
-2
model_zoo/official/nlp/bert/run_ner.py
model_zoo/official/nlp/bert/run_ner.py
+4
-2
model_zoo/official/nlp/bert/run_pretrain.py
model_zoo/official/nlp/bert/run_pretrain.py
+2
-2
model_zoo/official/nlp/bert/run_squad.py
model_zoo/official/nlp/bert/run_squad.py
+4
-2
model_zoo/official/nlp/tinybert/run_general_distill.py
model_zoo/official/nlp/tinybert/run_general_distill.py
+1
-1
model_zoo/official/nlp/tinybert/run_task_distill.py
model_zoo/official/nlp/tinybert/run_task_distill.py
+2
-2
未找到文件。
model_zoo/official/nlp/bert/run_classifier.py
浏览文件 @
9a1b81df
...
...
@@ -50,7 +50,7 @@ def do_train(dataset=None, network=None, load_checkpoint_path="", save_checkpoin
power
=
optimizer_cfg
.
AdamWeightDecay
.
power
)
params
=
net_with_loss
.
trainable_params
()
decay_params
=
list
(
filter
(
optimizer_cfg
.
AdamWeightDecay
.
decay_filter
,
params
))
other_params
=
list
(
filter
(
lambda
x
:
not
cfg
.
AdamWeightDecay
.
decay_filter
(
x
),
params
))
other_params
=
list
(
filter
(
lambda
x
:
not
optimizer_
cfg
.
AdamWeightDecay
.
decay_filter
(
x
),
params
))
group_params
=
[{
'params'
:
decay_params
,
'weight_decay'
:
optimizer_cfg
.
AdamWeightDecay
.
weight_decay
},
{
'params'
:
other_params
,
'weight_decay'
:
0.0
}]
...
...
@@ -70,7 +70,9 @@ def do_train(dataset=None, network=None, load_checkpoint_path="", save_checkpoin
# load checkpoint into network
ckpt_config
=
CheckpointConfig
(
save_checkpoint_steps
=
steps_per_epoch
,
keep_checkpoint_max
=
1
)
ckpoint_cb
=
ModelCheckpoint
(
prefix
=
"classifier"
,
directory
=
save_checkpoint_path
,
config
=
ckpt_config
)
ckpoint_cb
=
ModelCheckpoint
(
prefix
=
"classifier"
,
directory
=
None
if
save_checkpoint_path
==
""
else
save_checkpoint_path
,
config
=
ckpt_config
)
param_dict
=
load_checkpoint
(
load_checkpoint_path
)
load_param_into_net
(
network
,
param_dict
)
...
...
model_zoo/official/nlp/bert/run_ner.py
浏览文件 @
9a1b81df
...
...
@@ -52,7 +52,7 @@ def do_train(dataset=None, network=None, load_checkpoint_path="", save_checkpoin
power
=
optimizer_cfg
.
AdamWeightDecay
.
power
)
params
=
network
.
trainable_params
()
decay_params
=
list
(
filter
(
optimizer_cfg
.
AdamWeightDecay
.
decay_filter
,
params
))
other_params
=
list
(
filter
(
lambda
x
:
not
cfg
.
AdamWeightDecay
.
decay_filter
(
x
),
params
))
other_params
=
list
(
filter
(
lambda
x
:
not
optimizer_
cfg
.
AdamWeightDecay
.
decay_filter
(
x
),
params
))
group_params
=
[{
'params'
:
decay_params
,
'weight_decay'
:
optimizer_cfg
.
AdamWeightDecay
.
weight_decay
},
{
'params'
:
other_params
,
'weight_decay'
:
0.0
}]
optimizer
=
AdamWeightDecay
(
group_params
,
lr_schedule
,
eps
=
optimizer_cfg
.
AdamWeightDecay
.
eps
)
...
...
@@ -71,7 +71,9 @@ def do_train(dataset=None, network=None, load_checkpoint_path="", save_checkpoin
# load checkpoint into network
ckpt_config
=
CheckpointConfig
(
save_checkpoint_steps
=
steps_per_epoch
,
keep_checkpoint_max
=
1
)
ckpoint_cb
=
ModelCheckpoint
(
prefix
=
"ner"
,
directory
=
save_checkpoint_path
,
config
=
ckpt_config
)
ckpoint_cb
=
ModelCheckpoint
(
prefix
=
"ner"
,
directory
=
None
if
save_checkpoint_path
==
""
else
save_checkpoint_path
,
config
=
ckpt_config
)
param_dict
=
load_checkpoint
(
load_checkpoint_path
)
load_param_into_net
(
network
,
param_dict
)
...
...
model_zoo/official/nlp/bert/run_pretrain.py
浏览文件 @
9a1b81df
...
...
@@ -51,7 +51,7 @@ def run_pretrain():
parser
.
add_argument
(
"--do_shuffle"
,
type
=
str
,
default
=
"true"
,
help
=
"Enable shuffle for dataset, default is true."
)
parser
.
add_argument
(
"--enable_data_sink"
,
type
=
str
,
default
=
"true"
,
help
=
"Enable data sink, default is true."
)
parser
.
add_argument
(
"--data_sink_steps"
,
type
=
int
,
default
=
"1"
,
help
=
"Sink steps for each epoch, default is 1."
)
parser
.
add_argument
(
"--save_checkpoint_path"
,
type
=
str
,
default
=
""
,
help
=
"Save checkpoint path"
)
parser
.
add_argument
(
"--save_checkpoint_path"
,
type
=
str
,
default
=
None
,
help
=
"Save checkpoint path"
)
parser
.
add_argument
(
"--load_checkpoint_path"
,
type
=
str
,
default
=
""
,
help
=
"Load checkpoint file path"
)
parser
.
add_argument
(
"--save_checkpoint_steps"
,
type
=
int
,
default
=
1000
,
help
=
"Save checkpoint steps, "
"default is 1000."
)
...
...
@@ -142,7 +142,7 @@ def run_pretrain():
raise
ValueError
(
"Don't support optimizer {}, only support [Lamb, Momentum, AdamWeightDecay]"
.
format
(
cfg
.
optimizer
))
callback
=
[
TimeMonitor
(
args_opt
.
data_sink_steps
),
LossCallBack
()]
if
args_opt
.
enable_save_ckpt
==
"true"
:
if
args_opt
.
enable_save_ckpt
==
"true"
and
args_opt
.
device_id
%
min
(
8
,
device_num
)
==
0
:
config_ck
=
CheckpointConfig
(
save_checkpoint_steps
=
args_opt
.
save_checkpoint_steps
,
keep_checkpoint_max
=
args_opt
.
save_checkpoint_num
)
ckpoint_cb
=
ModelCheckpoint
(
prefix
=
'checkpoint_bert'
,
directory
=
ckpt_save_dir
,
config
=
config_ck
)
...
...
model_zoo/official/nlp/bert/run_squad.py
浏览文件 @
9a1b81df
...
...
@@ -52,7 +52,7 @@ def do_train(dataset=None, network=None, load_checkpoint_path="", save_checkpoin
power
=
optimizer_cfg
.
AdamWeightDecay
.
power
)
params
=
network
.
trainable_params
()
decay_params
=
list
(
filter
(
optimizer_cfg
.
AdamWeightDecay
.
decay_filter
,
params
))
other_params
=
list
(
filter
(
lambda
x
:
not
cfg
.
AdamWeightDecay
.
decay_filter
(
x
),
params
))
other_params
=
list
(
filter
(
lambda
x
:
not
optimizer_
cfg
.
AdamWeightDecay
.
decay_filter
(
x
),
params
))
group_params
=
[{
'params'
:
decay_params
,
'weight_decay'
:
optimizer_cfg
.
AdamWeightDecay
.
weight_decay
},
{
'params'
:
other_params
,
'weight_decay'
:
0.0
}]
...
...
@@ -72,7 +72,9 @@ def do_train(dataset=None, network=None, load_checkpoint_path="", save_checkpoin
# load checkpoint into network
ckpt_config
=
CheckpointConfig
(
save_checkpoint_steps
=
steps_per_epoch
,
keep_checkpoint_max
=
1
)
ckpoint_cb
=
ModelCheckpoint
(
prefix
=
"squad"
,
directory
=
save_checkpoint_path
,
config
=
ckpt_config
)
ckpoint_cb
=
ModelCheckpoint
(
prefix
=
"squad"
,
directory
=
None
if
save_checkpoint_path
==
""
else
save_checkpoint_path
,
config
=
ckpt_config
)
param_dict
=
load_checkpoint
(
load_checkpoint_path
)
load_param_into_net
(
network
,
param_dict
)
...
...
model_zoo/official/nlp/tinybert/run_general_distill.py
浏览文件 @
9a1b81df
...
...
@@ -99,7 +99,7 @@ def run_general_distill():
power
=
common_cfg
.
AdamWeightDecay
.
power
)
params
=
netwithloss
.
trainable_params
()
decay_params
=
list
(
filter
(
common_cfg
.
AdamWeightDecay
.
decay_filter
,
params
))
other_params
=
list
(
filter
(
lambda
x
:
not
cfg
.
AdamWeightDecay
.
decay_filter
(
x
),
params
))
other_params
=
list
(
filter
(
lambda
x
:
not
c
ommon_c
fg
.
AdamWeightDecay
.
decay_filter
(
x
),
params
))
group_params
=
[{
'params'
:
decay_params
,
'weight_decay'
:
common_cfg
.
AdamWeightDecay
.
weight_decay
},
{
'params'
:
other_params
,
'weight_decay'
:
0.0
},
{
'order_params'
:
params
}]
...
...
model_zoo/official/nlp/tinybert/run_task_distill.py
浏览文件 @
9a1b81df
...
...
@@ -107,7 +107,7 @@ def run_predistill():
power
=
optimizer_cfg
.
AdamWeightDecay
.
power
)
params
=
netwithloss
.
trainable_params
()
decay_params
=
list
(
filter
(
optimizer_cfg
.
AdamWeightDecay
.
decay_filter
,
params
))
other_params
=
list
(
filter
(
lambda
x
:
not
cfg
.
AdamWeightDecay
.
decay_filter
(
x
),
params
))
other_params
=
list
(
filter
(
lambda
x
:
not
optimizer_
cfg
.
AdamWeightDecay
.
decay_filter
(
x
),
params
))
group_params
=
[{
'params'
:
decay_params
,
'weight_decay'
:
optimizer_cfg
.
AdamWeightDecay
.
weight_decay
},
{
'params'
:
other_params
,
'weight_decay'
:
0.0
},
{
'order_params'
:
params
}]
...
...
@@ -165,7 +165,7 @@ def run_task_distill(ckpt_file):
power
=
optimizer_cfg
.
AdamWeightDecay
.
power
)
params
=
netwithloss
.
trainable_params
()
decay_params
=
list
(
filter
(
optimizer_cfg
.
AdamWeightDecay
.
decay_filter
,
params
))
other_params
=
list
(
filter
(
lambda
x
:
not
cfg
.
AdamWeightDecay
.
decay_filter
(
x
),
params
))
other_params
=
list
(
filter
(
lambda
x
:
not
optimizer_
cfg
.
AdamWeightDecay
.
decay_filter
(
x
),
params
))
group_params
=
[{
'params'
:
decay_params
,
'weight_decay'
:
optimizer_cfg
.
AdamWeightDecay
.
weight_decay
},
{
'params'
:
other_params
,
'weight_decay'
:
0.0
},
{
'order_params'
:
params
}]
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录