Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
magicwindyyd
mindspore
提交
668c18c4
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看板
提交
668c18c4
编写于
5月 21, 2020
作者:
C
chujinjin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix cifar 1p test
上级
65607a9d
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
4 addition
and
31 deletion
+4
-31
tests/st/tbe_networks/test_resnet_cifar_1p.py
tests/st/tbe_networks/test_resnet_cifar_1p.py
+4
-31
未找到文件。
tests/st/tbe_networks/test_resnet_cifar_1p.py
浏览文件 @
668c18c4
...
...
@@ -134,12 +134,8 @@ class LossGet(Callback):
return
self
.
_loss
def
train_process
(
device_id
,
epoch_size
,
num_classes
,
batch_size
):
os
.
system
(
"mkdir "
+
str
(
device_id
))
os
.
chdir
(
str
(
device_id
))
def
train_process
(
epoch_size
,
num_classes
,
batch_size
):
context
.
set_context
(
mode
=
context
.
GRAPH_MODE
,
device_target
=
"Ascend"
)
context
.
set_context
(
device_id
=
device_id
)
context
.
set_context
(
mode
=
context
.
GRAPH_MODE
)
net
=
resnet50
(
batch_size
,
num_classes
)
loss
=
CrossEntropyLoss
()
opt
=
Momentum
(
filter
(
lambda
x
:
x
.
requires_grad
,
...
...
@@ -148,34 +144,15 @@ def train_process(device_id, epoch_size, num_classes, batch_size):
model
=
Model
(
net
,
loss_fn
=
loss
,
optimizer
=
opt
,
metrics
=
{
'acc'
})
dataset
=
create_dataset
(
epoch_size
,
training
=
True
,
batch_size
=
batch_size
)
batch_num
=
dataset
.
get_dataset_size
()
config_ck
=
CheckpointConfig
(
save_checkpoint_steps
=
batch_num
,
keep_checkpoint_max
=
1
)
ckpoint_cb
=
ModelCheckpoint
(
prefix
=
"train_resnet_cifar10_device_id_"
+
str
(
device_id
),
directory
=
"./"
,
config
=
config_ck
)
loss_cb
=
LossGet
()
model
.
train
(
epoch_size
,
dataset
,
callbacks
=
[
ckpoint_cb
,
loss_cb
])
model
.
train
(
epoch_size
,
dataset
,
callbacks
=
[
loss_cb
])
def
eval
(
batch_size
,
num_classes
):
context
.
set_context
(
mode
=
context
.
GRAPH_MODE
,
device_target
=
"Ascend"
)
context
.
set_context
(
device_id
=
0
)
net
=
resnet50
(
batch_size
,
num_classes
)
loss
=
CrossEntropyLoss
()
opt
=
Momentum
(
filter
(
lambda
x
:
x
.
requires_grad
,
net
.
get_parameters
()),
0.01
,
0.9
)
model
=
Model
(
net
,
loss_fn
=
loss
,
optimizer
=
opt
,
metrics
=
{
'acc'
})
checkpoint_path
=
"./train_resnet_cifar10_device_id_0-1_1562.ckpt"
param_dict
=
load_checkpoint
(
checkpoint_path
)
load_param_into_net
(
net
,
param_dict
)
net
.
set_train
(
False
)
eval_dataset
=
create_dataset
(
1
,
training
=
False
)
res
=
model
.
eval
(
eval_dataset
)
print
(
"result: "
,
res
)
return
res
@
pytest
.
mark
.
level0
@
pytest
.
mark
.
platform_arm_ascend_training
@
pytest
.
mark
.
platform_x86_ascend_training
...
...
@@ -184,11 +161,7 @@ def test_resnet_cifar_1p():
epoch_size
=
1
num_classes
=
10
batch_size
=
32
device_id
=
0
train_process
(
device_id
,
epoch_size
,
num_classes
,
batch_size
)
time
.
sleep
(
3
)
acc
=
eval
(
batch_size
,
num_classes
)
os
.
chdir
(
"../"
)
os
.
system
(
"rm -rf "
+
str
(
device_id
))
acc
=
train_process
(
epoch_size
,
num_classes
,
batch_size
)
os
.
system
(
"rm -rf kernel_meta"
)
print
(
"End training..."
)
assert
acc
[
'acc'
]
>
0.35
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录