Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Oneflow-Inc
OneFlow-Benchmark
提交
447ed84d
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,发现更多精彩内容 >>
提交
447ed84d
编写于
6月 01, 2020
作者:
M
mir-of
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add bn for inceptionv3
上级
a114110c
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
46 addition
and
47 deletion
+46
-47
cnn_e2e/inception_model.py
cnn_e2e/inception_model.py
+46
-47
未找到文件。
cnn_e2e/inception_model.py
浏览文件 @
447ed84d
...
...
@@ -3,20 +3,20 @@ from __future__ import division
from
__future__
import
print_function
import
oneflow
as
flow
from
model_util
import
conv2d_layer
from
model_util
import
conv2d_layer
_with_bn
def
InceptionA
(
in_blob
,
index
):
with
flow
.
deprecated
.
variable_scope
(
"mixed_{}"
.
format
(
index
)):
with
flow
.
deprecated
.
variable_scope
(
"branch1x1"
):
branch1x1
=
conv2d_layer
(
branch1x1
=
conv2d_layer
_with_bn
(
"conv0"
,
in_blob
,
filters
=
64
,
kernel_size
=
1
,
strides
=
1
,
padding
=
"SAME"
)
with
flow
.
deprecated
.
variable_scope
(
"branch5x5"
):
branch5x5_1
=
conv2d_layer
(
branch5x5_1
=
conv2d_layer
_with_bn
(
"conv0"
,
in_blob
,
filters
=
48
,
kernel_size
=
1
,
strides
=
1
,
padding
=
"SAME"
)
branch5x5_2
=
conv2d_layer
(
branch5x5_2
=
conv2d_layer
_with_bn
(
"conv1"
,
branch5x5_1
,
filters
=
64
,
...
...
@@ -25,10 +25,10 @@ def InceptionA(in_blob, index):
padding
=
"SAME"
,
)
with
flow
.
deprecated
.
variable_scope
(
"branch3x3dbl"
):
branch3x3dbl_1
=
conv2d_layer
(
branch3x3dbl_1
=
conv2d_layer
_with_bn
(
"conv0"
,
in_blob
,
filters
=
64
,
kernel_size
=
1
,
strides
=
1
,
padding
=
"SAME"
)
branch3x3dbl_2
=
conv2d_layer
(
branch3x3dbl_2
=
conv2d_layer
_with_bn
(
"conv1"
,
branch3x3dbl_1
,
filters
=
96
,
...
...
@@ -36,7 +36,7 @@ def InceptionA(in_blob, index):
strides
=
1
,
padding
=
"SAME"
,
)
branch3x3dbl_3
=
conv2d_layer
(
branch3x3dbl_3
=
conv2d_layer
_with_bn
(
"conv2"
,
branch3x3dbl_2
,
filters
=
96
,
...
...
@@ -53,7 +53,7 @@ def InceptionA(in_blob, index):
data_format
=
"NCHW"
,
name
=
"pool"
,
)
branch_pool_2
=
conv2d_layer
(
branch_pool_2
=
conv2d_layer
_with_bn
(
"conv"
,
branch_pool_1
,
filters
=
32
if
index
==
0
else
64
,
...
...
@@ -76,14 +76,14 @@ def InceptionA(in_blob, index):
def
InceptionB
(
in_blob
,
index
):
with
flow
.
deprecated
.
variable_scope
(
"mixed_{}"
.
format
(
index
)):
with
flow
.
deprecated
.
variable_scope
(
"branch3x3"
):
branch3x3
=
conv2d_layer
(
branch3x3
=
conv2d_layer
_with_bn
(
"conv0"
,
in_blob
,
filters
=
384
,
kernel_size
=
3
,
strides
=
2
,
padding
=
"VALID"
)
with
flow
.
deprecated
.
variable_scope
(
"branch3x3dbl"
):
branch3x3dbl_1
=
conv2d_layer
(
branch3x3dbl_1
=
conv2d_layer
_with_bn
(
"conv0"
,
in_blob
,
filters
=
64
,
kernel_size
=
1
,
strides
=
1
,
padding
=
"SAME"
)
branch3x3dbl_2
=
conv2d_layer
(
branch3x3dbl_2
=
conv2d_layer
_with_bn
(
"conv1"
,
branch3x3dbl_1
,
filters
=
96
,
...
...
@@ -91,7 +91,7 @@ def InceptionB(in_blob, index):
strides
=
1
,
padding
=
"SAME"
,
)
branch3x3dbl_3
=
conv2d_layer
(
branch3x3dbl_3
=
conv2d_layer
_with_bn
(
"conv2"
,
branch3x3dbl_2
,
filters
=
96
,
...
...
@@ -121,11 +121,11 @@ def InceptionB(in_blob, index):
def
InceptionC
(
in_blob
,
index
,
filters
):
with
flow
.
deprecated
.
variable_scope
(
"mixed_{}"
.
format
(
index
)):
with
flow
.
deprecated
.
variable_scope
(
"branch1x1"
):
branch1x1
=
conv2d_layer
(
branch1x1
=
conv2d_layer
_with_bn
(
"conv0"
,
in_blob
,
filters
=
192
,
kernel_size
=
1
,
strides
=
1
,
padding
=
"SAME"
)
with
flow
.
deprecated
.
variable_scope
(
"branch7x7"
):
branch7x7_1
=
conv2d_layer
(
branch7x7_1
=
conv2d_layer
_with_bn
(
"conv0"
,
in_blob
,
filters
=
filters
,
...
...
@@ -133,7 +133,7 @@ def InceptionC(in_blob, index, filters):
strides
=
1
,
padding
=
"SAME"
,
)
branch7x7_2
=
conv2d_layer
(
branch7x7_2
=
conv2d_layer
_with_bn
(
"conv1"
,
branch7x7_1
,
filters
=
filters
,
...
...
@@ -141,7 +141,7 @@ def InceptionC(in_blob, index, filters):
strides
=
1
,
padding
=
"SAME"
,
)
branch7x7_3
=
conv2d_layer
(
branch7x7_3
=
conv2d_layer
_with_bn
(
"conv2"
,
branch7x7_2
,
filters
=
192
,
...
...
@@ -150,7 +150,7 @@ def InceptionC(in_blob, index, filters):
padding
=
"SAME"
,
)
with
flow
.
deprecated
.
variable_scope
(
"branch7x7dbl"
):
branch7x7dbl_1
=
conv2d_layer
(
branch7x7dbl_1
=
conv2d_layer
_with_bn
(
"conv0"
,
in_blob
,
filters
=
filters
,
...
...
@@ -158,7 +158,7 @@ def InceptionC(in_blob, index, filters):
strides
=
1
,
padding
=
"SAME"
,
)
branch7x7dbl_2
=
conv2d_layer
(
branch7x7dbl_2
=
conv2d_layer
_with_bn
(
"conv1"
,
branch7x7dbl_1
,
filters
=
filters
,
...
...
@@ -166,7 +166,7 @@ def InceptionC(in_blob, index, filters):
strides
=
1
,
padding
=
"SAME"
,
)
branch7x7dbl_3
=
conv2d_layer
(
branch7x7dbl_3
=
conv2d_layer
_with_bn
(
"conv2"
,
branch7x7dbl_2
,
filters
=
filters
,
...
...
@@ -174,7 +174,7 @@ def InceptionC(in_blob, index, filters):
strides
=
1
,
padding
=
"SAME"
,
)
branch7x7dbl_4
=
conv2d_layer
(
branch7x7dbl_4
=
conv2d_layer
_with_bn
(
"conv3"
,
branch7x7dbl_3
,
filters
=
filters
,
...
...
@@ -182,7 +182,7 @@ def InceptionC(in_blob, index, filters):
strides
=
1
,
padding
=
"SAME"
,
)
branch7x7dbl_5
=
conv2d_layer
(
branch7x7dbl_5
=
conv2d_layer
_with_bn
(
"conv4"
,
branch7x7dbl_4
,
filters
=
192
,
...
...
@@ -199,7 +199,7 @@ def InceptionC(in_blob, index, filters):
data_format
=
"NCHW"
,
name
=
"pool"
,
)
branch_pool_2
=
conv2d_layer
(
branch_pool_2
=
conv2d_layer
_with_bn
(
"conv"
,
branch_pool_1
,
filters
=
192
,
...
...
@@ -221,10 +221,10 @@ def InceptionC(in_blob, index, filters):
def
InceptionD
(
in_blob
,
index
):
with
flow
.
deprecated
.
variable_scope
(
"mixed_{}"
.
format
(
index
)):
with
flow
.
deprecated
.
variable_scope
(
"branch3x3"
):
branch3x3_1
=
conv2d_layer
(
branch3x3_1
=
conv2d_layer
_with_bn
(
"conv0"
,
in_blob
,
filters
=
192
,
kernel_size
=
1
,
strides
=
1
,
padding
=
"SAME"
)
branch3x3_2
=
conv2d_layer
(
branch3x3_2
=
conv2d_layer
_with_bn
(
"conv1"
,
branch3x3_1
,
filters
=
320
,
...
...
@@ -233,10 +233,10 @@ def InceptionD(in_blob, index):
padding
=
"VALID"
,
)
with
flow
.
deprecated
.
variable_scope
(
"branch7x7x3"
):
branch7x7x3_1
=
conv2d_layer
(
branch7x7x3_1
=
conv2d_layer
_with_bn
(
"conv0"
,
in_blob
,
filters
=
192
,
kernel_size
=
1
,
strides
=
1
,
padding
=
"SAME"
)
branch7x7x3_2
=
conv2d_layer
(
branch7x7x3_2
=
conv2d_layer
_with_bn
(
"conv1"
,
branch7x7x3_1
,
filters
=
192
,
...
...
@@ -244,7 +244,7 @@ def InceptionD(in_blob, index):
strides
=
1
,
padding
=
"SAME"
,
)
branch7x7x3_3
=
conv2d_layer
(
branch7x7x3_3
=
conv2d_layer
_with_bn
(
"conv2"
,
branch7x7x3_2
,
filters
=
192
,
...
...
@@ -252,7 +252,7 @@ def InceptionD(in_blob, index):
strides
=
1
,
padding
=
"SAME"
,
)
branch7x7x3_4
=
conv2d_layer
(
branch7x7x3_4
=
conv2d_layer
_with_bn
(
"conv3"
,
branch7x7x3_3
,
filters
=
192
,
...
...
@@ -283,14 +283,14 @@ def InceptionD(in_blob, index):
def
InceptionE
(
in_blob
,
index
):
with
flow
.
deprecated
.
variable_scope
(
"mixed_{}"
.
format
(
index
)):
with
flow
.
deprecated
.
variable_scope
(
"branch1x1"
):
branch1x1
=
conv2d_layer
(
branch1x1
=
conv2d_layer
_with_bn
(
"conv0"
,
in_blob
,
filters
=
320
,
kernel_size
=
1
,
strides
=
1
,
padding
=
"SAME"
)
with
flow
.
deprecated
.
variable_scope
(
"branch3x3"
):
branch3x3_1
=
conv2d_layer
(
branch3x3_1
=
conv2d_layer
_with_bn
(
"conv0"
,
in_blob
,
filters
=
384
,
kernel_size
=
1
,
strides
=
1
,
padding
=
"SAME"
)
branch3x3_2
=
conv2d_layer
(
branch3x3_2
=
conv2d_layer
_with_bn
(
"conv1"
,
branch3x3_1
,
filters
=
384
,
...
...
@@ -298,7 +298,7 @@ def InceptionE(in_blob, index):
strides
=
1
,
padding
=
"SAME"
,
)
branch3x3_3
=
conv2d_layer
(
branch3x3_3
=
conv2d_layer
_with_bn
(
"conv2"
,
branch3x3_1
,
filters
=
384
,
...
...
@@ -313,10 +313,10 @@ def InceptionE(in_blob, index):
values
=
inceptionE_1_bn
,
axis
=
1
,
name
=
"concat"
)
with
flow
.
deprecated
.
variable_scope
(
"branch3x3dbl"
):
branch3x3dbl_1
=
conv2d_layer
(
branch3x3dbl_1
=
conv2d_layer
_with_bn
(
"conv0"
,
in_blob
,
filters
=
448
,
kernel_size
=
1
,
strides
=
1
,
padding
=
"SAME"
)
branch3x3dbl_2
=
conv2d_layer
(
branch3x3dbl_2
=
conv2d_layer
_with_bn
(
"conv1"
,
branch3x3dbl_1
,
filters
=
384
,
...
...
@@ -324,7 +324,7 @@ def InceptionE(in_blob, index):
strides
=
1
,
padding
=
"SAME"
,
)
branch3x3dbl_3
=
conv2d_layer
(
branch3x3dbl_3
=
conv2d_layer
_with_bn
(
"conv2"
,
branch3x3dbl_2
,
filters
=
384
,
...
...
@@ -332,7 +332,7 @@ def InceptionE(in_blob, index):
strides
=
1
,
padding
=
"SAME"
,
)
branch3x3dbl_4
=
conv2d_layer
(
branch3x3dbl_4
=
conv2d_layer
_with_bn
(
"conv3"
,
branch3x3dbl_2
,
filters
=
384
,
...
...
@@ -355,7 +355,7 @@ def InceptionE(in_blob, index):
data_format
=
"NCHW"
,
name
=
"pool"
,
)
branch_pool_2
=
conv2d_layer
(
branch_pool_2
=
conv2d_layer
_with_bn
(
"conv"
,
branch_pool_1
,
filters
=
192
,
...
...
@@ -382,22 +382,23 @@ def inceptionv3(images, trainable=True, need_transpose=False):
images
=
flow
.
transpose
(
images
,
name
=
"transpose"
,
perm
=
[
0
,
3
,
1
,
2
])
with
flow
.
deprecated
.
variable_scope
(
"InceptionV3"
):
conv0
=
conv2d_layer
(
# conv0: 299 x 299 x 3
conv0
=
conv2d_layer_with_bn
(
"conv0"
,
images
,
filters
=
32
,
kernel_size
=
3
,
strides
=
2
,
padding
=
"VALID"
)
conv1
=
conv2d_layer
(
conv1
=
conv2d_layer
_with_bn
(
"conv1"
,
conv0
,
filters
=
32
,
kernel_size
=
3
,
strides
=
1
,
padding
=
"VALID"
)
conv2
=
conv2d_layer
(
conv2
=
conv2d_layer
_with_bn
(
"conv2"
,
conv1
,
filters
=
64
,
kernel_size
=
3
,
strides
=
1
,
padding
=
"SAME"
)
pool1
=
flow
.
nn
.
max_pool2d
(
conv2
,
ksize
=
3
,
strides
=
2
,
padding
=
"VALID"
,
data_format
=
"NCHW"
,
name
=
"pool1"
)
conv3
=
conv2d_layer
(
conv3
=
conv2d_layer
_with_bn
(
"conv3"
,
pool1
,
filters
=
80
,
kernel_size
=
1
,
strides
=
1
,
padding
=
"VALID"
)
conv4
=
conv2d_layer
(
conv4
=
conv2d_layer
_with_bn
(
"conv4"
,
conv3
,
filters
=
192
,
kernel_size
=
3
,
strides
=
1
,
padding
=
"VALID"
)
pool2
=
flow
.
nn
.
max_pool2d
(
...
...
@@ -408,7 +409,6 @@ def inceptionv3(images, trainable=True, need_transpose=False):
mixed_0
=
InceptionA
(
pool2
,
0
)
mixed_1
=
InceptionA
(
mixed_0
,
1
)
mixed_2
=
InceptionA
(
mixed_1
,
2
)
# mixed_3
mixed_3
=
InceptionB
(
mixed_2
,
3
)
...
...
@@ -425,7 +425,6 @@ def inceptionv3(images, trainable=True, need_transpose=False):
mixed_9
=
InceptionE
(
mixed_8
,
9
)
mixed_10
=
InceptionE
(
mixed_9
,
10
)
# pool3
pool3
=
flow
.
nn
.
avg_pool2d
(
mixed_10
,
ksize
=
8
,
strides
=
1
,
padding
=
"VALID"
,
data_format
=
"NCHW"
,
name
=
"pool3"
)
...
...
@@ -433,10 +432,10 @@ def inceptionv3(images, trainable=True, need_transpose=False):
# TODO: Need to transpose weight when converting model from TF to OF if
# you want to use layers.dense interface.
fc1
=
flow
.
layers
.
dense
(
flow
.
reshape
(
pool3
,
[
pool3
.
shape
[
0
],
-
1
]),
1001
,
inputs
=
flow
.
reshape
(
pool3
,
[
pool3
.
shape
[
0
],
-
1
]),
units
=
1001
,
activation
=
None
,
use_bias
=
Fals
e
,
use_bias
=
Tru
e
,
kernel_initializer
=
flow
.
truncated_normal
(
0.816496580927726
),
bias_initializer
=
flow
.
constant_initializer
(),
trainable
=
trainable
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录