Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Oneflow-Inc
OneFlow-Benchmark
提交
daed129e
O
OneFlow-Benchmark
项目概览
Oneflow-Inc
/
OneFlow-Benchmark
上一次同步 接近 3 年
通知
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,发现更多精彩内容 >>
提交
daed129e
编写于
5月 16, 2020
作者:
S
ShawnXuan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
work with cc's new dataloader
上级
c0e98bd4
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
41 addition
and
14 deletion
+41
-14
cnn_e2e/config.py
cnn_e2e/config.py
+5
-3
cnn_e2e/of_cnn_train_val.py
cnn_e2e/of_cnn_train_val.py
+3
-2
cnn_e2e/ofrecord_util.py
cnn_e2e/ofrecord_util.py
+28
-6
cnn_e2e/resnet_model.py
cnn_e2e/resnet_model.py
+3
-1
of_e2e.sh
of_e2e.sh
+2
-2
未找到文件。
cnn_e2e/config.py
浏览文件 @
daed129e
...
...
@@ -6,7 +6,7 @@ import argparse
from
datetime
import
datetime
import
logging
from
dali_util
import
add_dali_args
#
from dali_util import add_dali_args
from
optimizer_util
import
add_optimizer_args
from
ofrecord_util
import
add_ofrecord_args
...
...
@@ -48,6 +48,8 @@ def get_parser(parser=None):
parser
.
add_argument
(
'--rgb-std'
,
type
=
float_list
,
default
=
[
58.393
,
57.12
,
57.375
],
help
=
'a tuple of size 3 for the std rgb'
)
parser
.
add_argument
(
"--input_layout"
,
type
=
str
,
default
=
'NHWC'
,
help
=
"NCHW or NHWC"
)
parser
.
add_argument
(
'--image-shape'
,
type
=
int_list
,
default
=
[
3
,
224
,
224
],
help
=
'the image shape feed into the network'
)
## snapshot
...
...
@@ -65,7 +67,7 @@ def get_parser(parser=None):
default
=
1
,
help
=
"print loss every n iteration"
,
)
add_dali_args
(
parser
)
#
add_dali_args(parser)
add_ofrecord_args
(
parser
)
add_optimizer_args
(
parser
)
return
parser
...
...
cnn_e2e/of_cnn_train_val.py
浏览文件 @
daed129e
...
...
@@ -44,7 +44,8 @@ def TrainNet():
if
args
.
train_data_dir
:
assert
os
.
path
.
exists
(
args
.
train_data_dir
)
print
(
"Loading data from {}"
.
format
(
args
.
train_data_dir
))
(
labels
,
images
)
=
ofrecord_util
.
load_imagenet_for_training
(
args
)
(
labels
,
images
)
=
ofrecord_util
.
load_imagenet_for_training2
(
args
)
# note: images.shape = (N C H W) in cc's new dataloader(load_imagenet_for_training2)
else
:
print
(
"Loading synthetic data."
)
(
labels
,
images
)
=
ofrecord_util
.
load_synthetic
(
args
)
...
...
@@ -63,7 +64,7 @@ def InferenceNet():
if
args
.
val_data_dir
:
assert
os
.
path
.
exists
(
args
.
val_data_dir
)
print
(
"Loading data from {}"
.
format
(
args
.
val_data_dir
))
(
labels
,
images
)
=
ofrecord_util
.
load_imagenet_for_validation
(
args
)
(
labels
,
images
)
=
ofrecord_util
.
load_imagenet_for_validation
2
(
args
)
else
:
print
(
"Loading synthetic data."
)
(
labels
,
images
)
=
ofrecord_util
.
load_synthetic
(
args
)
...
...
cnn_e2e/ofrecord_util.py
浏览文件 @
daed129e
...
...
@@ -59,9 +59,9 @@ def load_imagenet_for_validation(args):
codec
=
flow
.
data
.
ImageCodec
(
[
#flow.data.ImagePreprocessor('bgr2rgb'),
flow
.
data
.
ImageTargetResizePreprocessor
(
resize_shorter
=
256
),
flow
.
data
.
ImageCenterCropPreprocessor
(
args
.
image_size
,
args
.
image_size
),
#
flow.data.ImageResizePreprocessor(args.image_size, args.image_size),
#
flow.data.ImageTargetResizePreprocessor(resize_shorter=256),
#
flow.data.ImageCenterCropPreprocessor(args.image_size, args.image_size),
flow
.
data
.
ImageResizePreprocessor
(
args
.
image_size
,
args
.
image_size
),
]
)
return
load_imagenet
(
args
,
val_batch_size
,
args
.
val_data_dir
,
args
.
val_data_part_num
,
codec
)
...
...
@@ -98,15 +98,37 @@ def load_imagenet_for_training2(args):
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
=
float
(
args
.
image_size
)
,
resize_y
=
float
(
args
.
image_size
)
,
rsz
=
flow
.
image
.
Resize
(
image
,
resize_x
=
args
.
image_size
,
resize_y
=
args
.
image_size
,
color_space
=
color_space
)
rng
=
flow
.
image
.
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
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"
):
ofrecord
=
flow
.
data
.
ofrecord_loader
(
args
.
val_data_dir
,
batch_size
=
val_batch_size
,
data_part_num
=
args
.
val_data_part_num
,
part_name_suffix_length
=
5
)
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
,
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
,
mean
=
args
.
rgb_mean
,
std
=
args
.
rgb_std
,
output_dtype
=
flow
.
float
)
return
label
,
normal
if
__name__
==
"__main__"
:
import
os
...
...
cnn_e2e/resnet_model.py
浏览文件 @
daed129e
...
...
@@ -127,7 +127,9 @@ def resnet_stem(input):
def
resnet50
(
images
,
trainable
=
True
):
images
=
flow
.
transpose
(
images
,
name
=
"transpose"
,
perm
=
[
0
,
3
,
1
,
2
])
# note: images.shape = (N C H W) in cc's new dataloader, transpose is not needed anymore
# images = flow.transpose(images, name="transpose", perm=[0, 3, 1, 2])
print
(
images
.
shape
,
"******************************"
)
with
flow
.
deprecated
.
variable_scope
(
"Resnet"
):
stem
=
resnet_stem
(
images
)
...
...
of_e2e.sh
浏览文件 @
daed129e
...
...
@@ -4,14 +4,14 @@ rm -rf ./output/snapshots/*
DATA_ROOT
=
/dataset/ImageNet/ofrecord
#DATA_ROOT=/dataset/imagenet-mxnet
#python3 cnn_benchmark/of_cnn_train_val.py \
#gdb --args \
#nvprof -f -o resnet.nvvp \
#gdb --args \
python3 cnn_e2e/of_cnn_train_val.py
\
--train_data_dir
=
$DATA_ROOT
/train
\
--train_data_part_num
=
256
\
--val_data_dir
=
$DATA_ROOT
/validation
\
--val_data_part_num
=
256
\
--num_nodes
=
2
\
--num_nodes
=
1
\
--node_ips
=
'11.11.1.12,11.11.1.14'
\
--gpu_num_per_node
=
4
\
--optimizer
=
"momentum-cosine-decay"
\
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录