Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
magicwindyyd
mindspore
提交
92d93ebc
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看板
提交
92d93ebc
编写于
8月 08, 2020
作者:
M
mindspore-ci-bot
提交者:
Gitee
8月 08, 2020
浏览文件
操作
浏览文件
下载
差异文件
!4041 modify mobilenetv2 quant scripts and fix bug
Merge pull request !4041 from chengxb7532/master
上级
ff6b90d9
63a477c4
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
15 addition
and
9 deletion
+15
-9
model_zoo/official/cv/mobilenetv2_quant/scripts/run_train_quant.sh
.../official/cv/mobilenetv2_quant/scripts/run_train_quant.sh
+5
-5
model_zoo/official/cv/mobilenetv2_quant/src/dataset.py
model_zoo/official/cv/mobilenetv2_quant/src/dataset.py
+8
-2
model_zoo/official/cv/mobilenetv2_quant/train.py
model_zoo/official/cv/mobilenetv2_quant/train.py
+2
-2
未找到文件。
model_zoo/official/cv/mobilenetv2_quant/scripts/run_train_quant.sh
浏览文件 @
92d93ebc
...
...
@@ -75,15 +75,15 @@ run_gpu()
python
${
BASEPATH
}
/../train.py
\
--dataset_path
=
$4
\
--device_target
=
$1
\
--
quantization_aware
=
True
\
&> ../train.log &
# dataset train folder
--
pre_trained
=
$5
\
--quantization_aware
=
True
&> ../train.log &
# dataset train folder
}
if
[
$#
-gt
6
]
||
[
$#
-lt
4
]
if
[
$#
-gt
6
]
||
[
$#
-lt
5
]
then
echo
"Usage:
\n
\
Ascend: sh run_train.sh Ascend [DEVICE_NUM] [SERVER_IP(x.x.x.x)] [VISIABLE_DEVICES(0,1,2,3,4,5,6,7)] [DATASET_PATH] [CKPT_PATH]
\n
\
GPU: sh run_train
.sh GPU [DEVICE_NUM] [VISIABLE_DEVICES(0,1,2,3,4,5,6,7)] [DATASE
T_PATH]
\n
\
Ascend: sh run_train
_quant
.sh Ascend [DEVICE_NUM] [SERVER_IP(x.x.x.x)] [VISIABLE_DEVICES(0,1,2,3,4,5,6,7)] [DATASET_PATH] [CKPT_PATH]
\n
\
GPU: sh run_train
_quant.sh GPU [DEVICE_NUM] [VISIABLE_DEVICES(0,1,2,3,4,5,6,7)] [DATASET_PATH] [CKP
T_PATH]
\n
\
"
exit
1
fi
...
...
model_zoo/official/cv/mobilenetv2_quant/src/dataset.py
浏览文件 @
92d93ebc
...
...
@@ -22,7 +22,6 @@ import mindspore.dataset.engine as de
import
mindspore.dataset.transforms.vision.c_transforms
as
C
import
mindspore.dataset.transforms.c_transforms
as
C2
import
mindspore.dataset.transforms.vision.py_transforms
as
P
from
src.config
import
config_ascend
def
create_dataset
(
dataset_path
,
do_train
,
config
,
device_target
,
repeat_num
=
1
,
batch_size
=
32
):
...
...
@@ -42,7 +41,7 @@ def create_dataset(dataset_path, do_train, config, device_target, repeat_num=1,
rank_size
=
int
(
os
.
getenv
(
"RANK_SIZE"
))
rank_id
=
int
(
os
.
getenv
(
"RANK_ID"
))
columns_list
=
[
'image'
,
'label'
]
if
config
_ascend
.
data_load_mode
==
"mindrecord"
:
if
config
.
data_load_mode
==
"mindrecord"
:
load_func
=
partial
(
de
.
MindDataset
,
dataset_path
,
columns_list
)
else
:
load_func
=
partial
(
de
.
ImageFolderDatasetV2
,
dataset_path
)
...
...
@@ -54,6 +53,13 @@ def create_dataset(dataset_path, do_train, config, device_target, repeat_num=1,
num_shards
=
rank_size
,
shard_id
=
rank_id
)
else
:
ds
=
load_func
(
num_parallel_workers
=
8
,
shuffle
=
False
)
elif
device_target
==
"GPU"
:
if
do_train
:
from
mindspore.communication.management
import
get_rank
,
get_group_size
ds
=
de
.
ImageFolderDatasetV2
(
dataset_path
,
num_parallel_workers
=
8
,
shuffle
=
True
,
num_shards
=
get_group_size
(),
shard_id
=
get_rank
())
else
:
ds
=
de
.
ImageFolderDatasetV2
(
dataset_path
,
num_parallel_workers
=
8
,
shuffle
=
True
)
else
:
raise
ValueError
(
"Unsupport device_target."
)
...
...
model_zoo/official/cv/mobilenetv2_quant/train.py
浏览文件 @
92d93ebc
...
...
@@ -56,7 +56,7 @@ if args_opt.device_target == "Ascend":
context
.
set_context
(
mode
=
context
.
GRAPH_MODE
,
device_target
=
"Ascend"
,
device_id
=
device_id
,
save_graphs
=
False
)
elif
args_opt
.
platform
==
"GPU"
:
elif
args_opt
.
device_target
==
"GPU"
:
init
(
"nccl"
)
context
.
set_auto_parallel_context
(
device_num
=
get_group_size
(),
parallel_mode
=
ParallelMode
.
DATA_PARALLEL
,
...
...
@@ -205,5 +205,5 @@ def train_on_gpu():
if
__name__
==
'__main__'
:
if
args_opt
.
device_target
==
"Ascend"
:
train_on_ascend
()
elif
args_opt
.
platform
==
"GPU"
:
elif
args_opt
.
device_target
==
"GPU"
:
train_on_gpu
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录