Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
正统之独孤求败
mindspore
提交
0c176132
M
mindspore
项目概览
正统之独孤求败
/
mindspore
与 Fork 源项目一致
Fork自
MindSpore / mindspore
通知
1
Star
0
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
0c176132
编写于
7月 21, 2020
作者:
D
dessyang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add the necessary rescale op and the option of not shuffling validation data
上级
ade60ad3
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
9 addition
and
8 deletion
+9
-8
model_zoo/googlenet/src/dataset.py
model_zoo/googlenet/src/dataset.py
+9
-8
未找到文件。
model_zoo/googlenet/src/dataset.py
浏览文件 @
0c176132
...
...
@@ -32,7 +32,10 @@ def create_dataset(data_home, repeat_num=1, training=True):
data_dir
=
os
.
path
.
join
(
data_home
,
"cifar-10-verify-bin"
)
rank_size
,
rank_id
=
_get_rank_info
()
data_set
=
ds
.
Cifar10Dataset
(
data_dir
,
num_shards
=
rank_size
,
shard_id
=
rank_id
)
if
training
:
data_set
=
ds
.
Cifar10Dataset
(
data_dir
,
num_shards
=
rank_size
,
shard_id
=
rank_id
,
shuffle
=
True
)
else
:
data_set
=
ds
.
Cifar10Dataset
(
data_dir
,
num_shards
=
rank_size
,
shard_id
=
rank_id
,
shuffle
=
False
)
resize_height
=
cfg
.
image_height
resize_width
=
cfg
.
image_width
...
...
@@ -41,6 +44,7 @@ def create_dataset(data_home, repeat_num=1, training=True):
random_crop_op
=
vision
.
RandomCrop
((
32
,
32
),
(
4
,
4
,
4
,
4
))
# padding_mode default CONSTANT
random_horizontal_op
=
vision
.
RandomHorizontalFlip
()
resize_op
=
vision
.
Resize
((
resize_height
,
resize_width
))
# interpolation default BILINEAR
rescale_op
=
vision
.
Rescale
(
1.0
/
255.0
,
0.0
)
normalize_op
=
vision
.
Normalize
((
0.4914
,
0.4822
,
0.4465
),
(
0.2023
,
0.1994
,
0.2010
))
changeswap_op
=
vision
.
HWC2CHW
()
type_cast_op
=
C
.
TypeCast
(
mstype
.
int32
)
...
...
@@ -48,21 +52,18 @@ def create_dataset(data_home, repeat_num=1, training=True):
c_trans
=
[]
if
training
:
c_trans
=
[
random_crop_op
,
random_horizontal_op
]
c_trans
+=
[
resize_op
,
normalize_op
,
changeswap_op
]
c_trans
+=
[
resize_op
,
rescale_op
,
normalize_op
,
changeswap_op
]
# apply map operations on images
data_set
=
data_set
.
map
(
input_columns
=
"label"
,
operations
=
type_cast_op
)
data_set
=
data_set
.
map
(
input_columns
=
"image"
,
operations
=
c_trans
)
# apply repeat operations
data_set
=
data_set
.
repeat
(
repeat_num
)
# apply shuffle operations
data_set
=
data_set
.
shuffle
(
buffer_size
=
10
)
# apply batch operations
data_set
=
data_set
.
batch
(
batch_size
=
cfg
.
batch_size
,
drop_remainder
=
True
)
# apply repeat operations
data_set
=
data_set
.
repeat
(
repeat_num
)
return
data_set
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录