Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
X2Paddle
提交
58bdbdc5
X
X2Paddle
项目概览
PaddlePaddle
/
X2Paddle
大约 1 年 前同步成功
通知
328
Star
698
Fork
167
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
26
列表
看板
标记
里程碑
合并请求
4
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
X
X2Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
26
Issue
26
列表
看板
标记
里程碑
合并请求
4
合并请求
4
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
58bdbdc5
编写于
2月 25, 2021
作者:
J
Jason
提交者:
GitHub
2月 25, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #514 from SunAhong1993/develop
caffe bn输入为2维的情况
上级
57e500f8
8085ee04
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
60 addition
and
14 deletion
+60
-14
x2paddle/op_mapper/dygraph/caffe2paddle/caffe_op_mapper.py
x2paddle/op_mapper/dygraph/caffe2paddle/caffe_op_mapper.py
+30
-7
x2paddle/op_mapper/static/caffe2paddle/caffe_op_mapper.py
x2paddle/op_mapper/static/caffe2paddle/caffe_op_mapper.py
+30
-7
未找到文件。
x2paddle/op_mapper/dygraph/caffe2paddle/caffe_op_mapper.py
浏览文件 @
58bdbdc5
...
@@ -697,11 +697,23 @@ class CaffeOpMapper(OpMapper):
...
@@ -697,11 +697,23 @@ class CaffeOpMapper(OpMapper):
"weight_attr"
:
False
,
"weight_attr"
:
False
,
"bias_attr"
:
False
,
"bias_attr"
:
False
,
}
}
if
len
(
node
.
in_shapes
[
0
])
==
2
:
self
.
paddle_graph
.
add_layer
(
"paddle.unsqueeze"
,
inputs
=
{
"x"
:
input
.
name
},
outputs
=
[
input
.
name
],
axis
=
[
2
,
3
])
self
.
paddle_graph
.
add_layer
(
self
.
paddle_graph
.
add_layer
(
"paddle.nn.BatchNorm2D"
,
"paddle.nn.BatchNorm2D"
,
inputs
=
{
"input"
:
input
.
name
},
inputs
=
{
"input"
:
input
.
name
},
outputs
=
layer_outputs
,
outputs
=
layer_outputs
,
**
layer_attrs
)
**
layer_attrs
)
if
len
(
node
.
in_shapes
[
0
])
==
2
:
self
.
paddle_graph
.
add_layer
(
"paddle.squeeze"
,
inputs
=
{
"x"
:
node
.
layer_name
},
outputs
=
[
node
.
layer_name
],
axis
=
[
2
,
3
])
def
Scale
(
self
,
node
):
def
Scale
(
self
,
node
):
if
node
.
data
is
None
:
if
node
.
data
is
None
:
...
@@ -717,6 +729,11 @@ class CaffeOpMapper(OpMapper):
...
@@ -717,6 +729,11 @@ class CaffeOpMapper(OpMapper):
else
:
else
:
self
.
params
[
node
.
layer_name
+
"_cparam1"
]
=
np
.
squeeze
(
node
.
data
[
self
.
params
[
node
.
layer_name
+
"_cparam1"
]
=
np
.
squeeze
(
node
.
data
[
0
]).
astype
(
"float32"
)
0
]).
astype
(
"float32"
)
if
not
node
.
layer
.
scale_param
.
bias_term
:
self
.
params
[
node
.
layer_name
+
"_cparam2"
]
=
np
.
zeros
([
node
.
in_shapes
[
0
][
1
],
]).
astype
(
"float32"
)
else
:
self
.
params
[
node
.
layer_name
+
"_cparam2"
]
=
np
.
squeeze
(
node
.
data
[
self
.
params
[
node
.
layer_name
+
"_cparam2"
]
=
np
.
squeeze
(
node
.
data
[
1
]).
astype
(
"float32"
)
1
]).
astype
(
"float32"
)
params
=
node
.
layer
.
scale_param
params
=
node
.
layer
.
scale_param
...
@@ -747,6 +764,12 @@ class CaffeOpMapper(OpMapper):
...
@@ -747,6 +764,12 @@ class CaffeOpMapper(OpMapper):
inputs_dict
=
{}
inputs_dict
=
{}
inputs_dict
[
'x'
]
=
input0_name
inputs_dict
[
'x'
]
=
input0_name
inputs_dict
[
'y'
]
=
node
.
layer_name
+
"_cparam1"
inputs_dict
[
'y'
]
=
node
.
layer_name
+
"_cparam1"
if
len
(
node
.
in_shapes
[
0
])
==
2
:
self
.
paddle_graph
.
add_layer
(
"paddle.multiply"
,
inputs
=
inputs_dict
,
outputs
=
[
node
.
layer_name
+
"_mul"
])
else
:
self
.
paddle_graph
.
add_layer
(
self
.
paddle_graph
.
add_layer
(
"paddle.multiply"
,
"paddle.multiply"
,
inputs
=
inputs_dict
,
inputs
=
inputs_dict
,
...
...
x2paddle/op_mapper/static/caffe2paddle/caffe_op_mapper.py
浏览文件 @
58bdbdc5
...
@@ -771,6 +771,12 @@ class CaffeOpMapper(OpMapper):
...
@@ -771,6 +771,12 @@ class CaffeOpMapper(OpMapper):
'epsilon'
:
eps
,
'epsilon'
:
eps
,
'momentum'
:
momentum
'momentum'
:
momentum
}
}
if
len
(
node
.
in_shapes
[
0
])
==
2
:
self
.
paddle_graph
.
add_layer
(
"paddle.unsqueeze"
,
inputs
=
{
"x"
:
input
.
name
},
outputs
=
[
input
.
name
],
axis
=
[
2
,
3
])
self
.
paddle_graph
.
add_layer
(
self
.
paddle_graph
.
add_layer
(
kernel
=
"paddle.nn.functional.batch_norm"
,
kernel
=
"paddle.nn.functional.batch_norm"
,
inputs
=
{
"x"
:
input
.
name
,
inputs
=
{
"x"
:
input
.
name
,
...
@@ -780,6 +786,12 @@ class CaffeOpMapper(OpMapper):
...
@@ -780,6 +786,12 @@ class CaffeOpMapper(OpMapper):
"running_var"
:
variance_name
,},
"running_var"
:
variance_name
,},
outputs
=
[
node
.
name
],
outputs
=
[
node
.
name
],
**
layer_attrs
)
**
layer_attrs
)
if
len
(
node
.
in_shapes
[
0
])
==
2
:
self
.
paddle_graph
.
add_layer
(
"paddle.squeeze"
,
inputs
=
{
"x"
:
node
.
layer_name
},
outputs
=
[
node
.
layer_name
],
axis
=
[
2
,
3
])
def
Scale
(
self
,
node
):
def
Scale
(
self
,
node
):
if
node
.
data
is
None
:
if
node
.
data
is
None
:
...
@@ -795,7 +807,12 @@ class CaffeOpMapper(OpMapper):
...
@@ -795,7 +807,12 @@ class CaffeOpMapper(OpMapper):
else
:
else
:
self
.
params
[
node
.
name
+
"_cparam1"
]
=
np
.
squeeze
(
node
.
data
[
self
.
params
[
node
.
name
+
"_cparam1"
]
=
np
.
squeeze
(
node
.
data
[
0
]).
astype
(
"float32"
)
0
]).
astype
(
"float32"
)
self
.
params
[
node
.
name
+
"_cparam2"
]
=
np
.
squeeze
(
node
.
data
[
if
not
node
.
layer
.
scale_param
.
bias_term
:
self
.
params
[
node
.
layer_name
+
"_cparam2"
]
=
np
.
zeros
([
node
.
in_shapes
[
0
][
1
],
]).
astype
(
"float32"
)
else
:
self
.
params
[
node
.
layer_name
+
"_cparam2"
]
=
np
.
squeeze
(
node
.
data
[
1
]).
astype
(
"float32"
)
1
]).
astype
(
"float32"
)
params
=
node
.
layer
.
scale_param
params
=
node
.
layer
.
scale_param
axis
=
params
.
axis
axis
=
params
.
axis
...
@@ -826,10 +843,16 @@ class CaffeOpMapper(OpMapper):
...
@@ -826,10 +843,16 @@ class CaffeOpMapper(OpMapper):
inputs_dict
=
{}
inputs_dict
=
{}
inputs_dict
[
'x'
]
=
input0_name
inputs_dict
[
'x'
]
=
input0_name
inputs_dict
[
'y'
]
=
node
.
name
+
"_cparam1"
inputs_dict
[
'y'
]
=
node
.
name
+
"_cparam1"
if
len
(
node
.
in_shapes
[
0
])
==
2
:
self
.
paddle_graph
.
add_layer
(
self
.
paddle_graph
.
add_layer
(
"paddle.multiply"
,
"paddle.multiply"
,
inputs
=
inputs_dict
,
inputs
=
inputs_dict
,
outputs
=
[
node
.
name
+
"_mul"
],
outputs
=
[
node
.
layer_name
+
"_mul"
])
else
:
self
.
paddle_graph
.
add_layer
(
"paddle.multiply"
,
inputs
=
inputs_dict
,
outputs
=
[
node
.
layer_name
+
"_mul"
],
axis
=
axis
)
axis
=
axis
)
self
.
paddle_graph
.
add_layer
(
self
.
paddle_graph
.
add_layer
(
"paddle.static.create_parameter"
,
"paddle.static.create_parameter"
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录