Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Oneflow-Inc
OneFlow-Benchmark
提交
7015966e
O
OneFlow-Benchmark
项目概览
Oneflow-Inc
/
OneFlow-Benchmark
上一次同步 2 年多
通知
1
Star
92
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
OneFlow-Benchmark
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
7015966e
编写于
5月 29, 2020
作者:
S
ShawnXuan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
new dataloader
上级
528682fb
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
11 addition
and
15 deletion
+11
-15
cnn_e2e/ofrecord_util.py
cnn_e2e/ofrecord_util.py
+11
-15
未找到文件。
cnn_e2e/ofrecord_util.py
浏览文件 @
7015966e
...
...
@@ -6,6 +6,7 @@ import oneflow as flow
def
add_ofrecord_args
(
parser
):
parser
.
add_argument
(
"--image_size"
,
type
=
int
,
default
=
224
,
required
=
False
,
help
=
"image size"
)
parser
.
add_argument
(
"--resize_shorter"
,
type
=
int
,
default
=
256
,
required
=
False
,
help
=
"resize shorter for validation"
)
parser
.
add_argument
(
"--train_data_dir"
,
type
=
str
,
default
=
None
,
help
=
"train dataset directory"
)
parser
.
add_argument
(
"--train_data_part_num"
,
type
=
int
,
default
=
256
,
help
=
"train data part num"
)
parser
.
add_argument
(
"--val_data_dir"
,
type
=
str
,
default
=
None
,
help
=
"val dataset directory"
)
...
...
@@ -88,22 +89,21 @@ def load_imagenet_for_training2(args):
total_device_num
=
args
.
num_nodes
*
args
.
gpu_num_per_node
train_batch_size
=
total_device_num
*
args
.
batch_size_per_device
seed
=
0
color_space
=
'RGB'
with
flow
.
fixed_placement
(
"cpu"
,
"0:0
"
):
with
flow
.
fixed_placement
(
"cpu"
,
"0:0
-{}"
.
format
(
args
.
gpu_num_per_node
-
1
)
):
ofrecord
=
flow
.
data
.
ofrecord_reader
(
args
.
train_data_dir
,
batch_size
=
train_batch_size
,
data_part_num
=
args
.
train_data_part_num
,
part_name_suffix_length
=
5
,
random_shuffle
=
True
,
shuffle_after_epoch
=
True
)
image
=
flow
.
data
.
OFRecordImageDecoderRandomCrop
(
ofrecord
,
"encoded"
,
seed
=
seed
,
image
=
flow
.
data
.
OFRecordImageDecoderRandomCrop
(
ofrecord
,
"encoded"
,
#
seed=seed,
color_space
=
color_space
)
label
=
flow
.
data
.
OFRecordRawDecoder
(
ofrecord
,
"class/label"
,
shape
=
(),
dtype
=
flow
.
int32
)
rsz
=
flow
.
image
.
Resize
(
image
,
resize_x
=
args
.
image_size
,
resize_y
=
args
.
image_size
,
rsz
=
flow
.
image
.
Resize
(
image
,
resize_x
=
args
.
image_size
,
resize_y
=
args
.
image_size
,
color_space
=
color_space
)
rng
=
flow
.
random
.
CoinFlip
(
batch_size
=
train_batch_size
,
seed
=
seed
)
rng
=
flow
.
random
.
CoinFlip
(
batch_size
=
train_batch_size
)
#
, seed=seed)
normal
=
flow
.
image
.
CropMirrorNormalize
(
rsz
,
mirror_blob
=
rng
,
color_space
=
color_space
,
mean
=
args
.
rgb_mean
,
std
=
args
.
rgb_std
,
output_dtype
=
flow
.
float
)
return
label
,
normal
...
...
@@ -112,23 +112,19 @@ def load_imagenet_for_validation2(args):
total_device_num
=
args
.
num_nodes
*
args
.
gpu_num_per_node
val_batch_size
=
total_device_num
*
args
.
val_batch_size_per_device
seed
=
0
color_space
=
'RGB'
with
flow
.
fixed_placement
(
"cpu"
,
"0:0
"
):
with
flow
.
fixed_placement
(
"cpu"
,
"0:0
-{}"
.
format
(
args
.
gpu_num_per_node
-
1
)
):
ofrecord
=
flow
.
data
.
ofrecord_reader
(
args
.
val_data_dir
,
batch_size
=
val_batch_size
,
data_part_num
=
args
.
val_data_part_num
,
part_name_suffix_length
=
5
,
shuffle_after_epoch
=
False
)
image
=
flow
.
data
.
OFRecordImageDecoderRandomCrop
(
ofrecord
,
"encoded"
,
seed
=
seed
,
color_space
=
color_space
)
image
=
flow
.
data
.
OFRecordImageDecoder
(
ofrecord
,
"encoded"
,
color_space
=
color_space
)
label
=
flow
.
data
.
OFRecordRawDecoder
(
ofrecord
,
"class/label"
,
shape
=
(),
dtype
=
flow
.
int32
)
rsz
=
flow
.
image
.
Resize
(
image
,
resize_x
=
args
.
image_size
,
resize_y
=
args
.
image_size
,
color_space
=
color_space
)
rsz
=
flow
.
image
.
Resize
(
image
,
resize_shorter
=
args
.
resize_shorter
,
color_space
=
color_space
)
rng
=
flow
.
random
.
CoinFlip
(
batch_size
=
val_batch_size
,
seed
=
seed
)
normal
=
flow
.
image
.
CropMirrorNormalize
(
rsz
,
mirror_blob
=
rng
,
color_space
=
color_space
,
normal
=
flow
.
image
.
CropMirrorNormalize
(
rsz
,
color_space
=
color_space
,
crop_h
=
args
.
image_size
,
crop_w
=
args
.
image_size
,
crop_pos_y
=
0.5
,
crop_pos_x
=
0.5
,
mean
=
args
.
rgb_mean
,
std
=
args
.
rgb_std
,
output_dtype
=
flow
.
float
)
return
label
,
normal
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录