Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
magicwindyyd
mindspore
提交
d14221ea
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看板
提交
d14221ea
编写于
9月 07, 2020
作者:
M
mindspore-ci-bot
提交者:
Gitee
9月 07, 2020
浏览文件
操作
浏览文件
下载
差异文件
!5849 mobilenetv2 modify api and debug
Merge pull request !5849 from yepei6/mobilenetv2
上级
bbafa9db
d6278c2b
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
11 addition
and
10 deletion
+11
-10
model_zoo/official/cv/mobilenetv2/eval.py
model_zoo/official/cv/mobilenetv2/eval.py
+2
-2
model_zoo/official/cv/mobilenetv2/scripts/run_train.sh
model_zoo/official/cv/mobilenetv2/scripts/run_train.sh
+2
-2
model_zoo/official/cv/mobilenetv2/src/args.py
model_zoo/official/cv/mobilenetv2/src/args.py
+2
-2
model_zoo/official/cv/mobilenetv2/src/launch.py
model_zoo/official/cv/mobilenetv2/src/launch.py
+2
-2
model_zoo/official/cv/mobilenetv2/src/utils.py
model_zoo/official/cv/mobilenetv2/src/utils.py
+2
-1
model_zoo/official/cv/mobilenetv2/train.py
model_zoo/official/cv/mobilenetv2/train.py
+1
-1
未找到文件。
model_zoo/official/cv/mobilenetv2/eval.py
浏览文件 @
d14221ea
...
...
@@ -32,7 +32,7 @@ if __name__ == '__main__':
backbone_net
=
MobileNetV2Backbone
(
platform
=
args_opt
.
platform
)
head_net
=
MobileNetV2Head
(
input_channel
=
backbone_net
.
out_channels
,
num_classes
=
config
.
num_classes
)
net
=
mobilenet_v2
(
featur
e_net
,
head_net
)
net
=
mobilenet_v2
(
backbon
e_net
,
head_net
)
#load the trained checkpoint file to the net for evaluation
if
args_opt
.
head_ckpt
:
...
...
@@ -51,7 +51,7 @@ if __name__ == '__main__':
loss
=
nn
.
SoftmaxCrossEntropyWithLogits
(
sparse
=
True
,
reduction
=
'mean'
)
model
=
Model
(
net
,
loss_fn
=
loss
,
metrics
=
{
'acc'
})
res
=
model
.
eval
(
dataset
)
res
=
model
.
eval
(
dataset
,
dataset_sink_mode
=
False
)
print
(
f
"result:
{
res
}
\n
pretrain_ckpt=
{
args_opt
.
pretrain_ckpt
}
"
)
if
args_opt
.
head_ckpt
:
print
(
f
"head_ckpt=
{
args_opt
.
head_ckpt
}
"
)
model_zoo/official/cv/mobilenetv2/scripts/run_train.sh
浏览文件 @
d14221ea
...
...
@@ -84,9 +84,9 @@ run_gpu()
run_cpu
()
{
if
[
!
-d
$
4
]
if
[
!
-d
$
2
]
then
echo
"error: DATASET_PATH=
$
4
is not a directory"
echo
"error: DATASET_PATH=
$
2
is not a directory"
exit
1
fi
...
...
model_zoo/official/cv/mobilenetv2/src/args.py
浏览文件 @
d14221ea
...
...
@@ -22,7 +22,7 @@ def launch_parse_args():
that will spawn up multiple distributed processes"
)
launch_parser
.
add_argument
(
'--platform'
,
type
=
str
,
default
=
"Ascend"
,
choices
=
(
"Ascend"
,
"GPU"
,
"CPU"
),
\
help
=
'run platform, only support GPU, CPU and Ascend'
)
launch_parser
.
add_argument
(
"--nproc_per_node"
,
type
=
int
,
default
=
1
,
choices
=
(
0
,
1
,
2
,
3
,
4
,
5
,
6
,
7
),
\
launch_parser
.
add_argument
(
"--nproc_per_node"
,
type
=
int
,
default
=
1
,
choices
=
(
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
),
\
help
=
"The number of processes to launch on each node, for D training, this is recommended to be set
\
to the number of D in your system so that each process can be bound to a single D."
)
launch_parser
.
add_argument
(
"--visible_devices"
,
type
=
str
,
default
=
"0,1,2,3,4,5,6,7"
,
help
=
"will use the
\
...
...
@@ -32,7 +32,7 @@ def launch_parse_args():
the training script"
)
launch_args
,
unknown
=
launch_parser
.
parse_known_args
()
launch_args
.
train_script_args
=
unknown
launch_args
.
train
ing
_script_args
=
unknown
launch_args
.
training_script_args
+=
[
"--platform"
,
launch_args
.
platform
]
return
launch_args
...
...
model_zoo/official/cv/mobilenetv2/src/launch.py
浏览文件 @
d14221ea
...
...
@@ -46,8 +46,8 @@ def main():
os
.
mkdir
(
device_dir
)
os
.
chdir
(
device_dir
)
cmd
=
[
sys
.
executable
,
'-u'
]
cmd
.
append
(
args
.
train_script
)
cmd
.
extend
(
args
.
train_script_args
)
cmd
.
append
(
args
.
train
ing
_script
)
cmd
.
extend
(
args
.
train
ing
_script_args
)
log_file
=
open
(
'{dir}/log{id}.log'
.
format
(
dir
=
device_dir
,
id
=
rank_id
),
'w'
)
process
=
subprocess
.
Popen
(
cmd
,
stdout
=
log_file
,
stderr
=
log_file
,
env
=
env
)
processes
.
append
(
process
)
...
...
model_zoo/official/cv/mobilenetv2/src/utils.py
浏览文件 @
d14221ea
...
...
@@ -17,8 +17,9 @@ from mindspore import context
from
mindspore
import
nn
from
mindspore.common
import
dtype
as
mstype
from
mindspore.train.model
import
ParallelMode
from
mindspore.parallel._auto_parallel_context
import
auto_parallel_context
from
mindspore.train.callback
import
ModelCheckpoint
,
CheckpointConfig
from
mindspore.communication.management
import
get_rank
,
init
from
mindspore.communication.management
import
get_rank
,
init
,
get_group_size
from
src.models
import
Monitor
...
...
model_zoo/official/cv/mobilenetv2/train.py
浏览文件 @
d14221ea
...
...
@@ -88,7 +88,7 @@ if __name__ == '__main__':
opt
=
Momentum
(
filter
(
lambda
x
:
x
.
requires_grad
,
net
.
get_parameters
()),
lr
,
config
.
momentum
,
config
.
weight_decay
)
network
=
WithLossCell
(
net
,
loss
)
network
=
TrainOneStepCell
(
net
,
opt
)
network
=
TrainOneStepCell
(
net
work
,
opt
)
network
.
set_train
()
features_path
=
args_opt
.
dataset_path
+
'_features'
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录