Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
X2Paddle
提交
a20d95a7
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看板
未验证
提交
a20d95a7
编写于
6月 29, 2021
作者:
W
WJJ1995
提交者:
GitHub
6月 29, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fixed LRN bug (#631)
上级
8eca2774
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
1 addition
and
64 deletion
+1
-64
x2paddle/op_mapper/onnx2paddle/onnx_custom_layer/__init__.py
x2paddle/op_mapper/onnx2paddle/onnx_custom_layer/__init__.py
+0
-1
x2paddle/op_mapper/onnx2paddle/onnx_custom_layer/lrn.py
x2paddle/op_mapper/onnx2paddle/onnx_custom_layer/lrn.py
+0
-62
x2paddle/op_mapper/onnx2paddle/opset9/opset.py
x2paddle/op_mapper/onnx2paddle/opset9/opset.py
+1
-1
未找到文件。
x2paddle/op_mapper/onnx2paddle/onnx_custom_layer/__init__.py
浏览文件 @
a20d95a7
...
...
@@ -17,5 +17,4 @@ from .pad_two_input import PadWithTwoInput
from
.pad_all_dim2
import
PadAllDim2
from
.pad_all_dim4
import
PadAllDim4
from
.pad_all_dim4_one_input
import
PadAllDim4WithOneInput
from
.lrn
import
LocalResponseNorm
from
.nms
import
NMS
x2paddle/op_mapper/onnx2paddle/onnx_custom_layer/lrn.py
已删除
100644 → 0
浏览文件 @
8eca2774
# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import
paddle
class
LocalResponseNorm
(
object
):
def
__init__
(
self
,
size
,
alpha
=
1e-4
,
beta
=
0.75
,
k
=
1.
):
self
.
size
=
size
self
.
alpha
=
alpha
self
.
beta
=
beta
self
.
k
=
k
def
__call__
(
self
,
x
):
sizes
=
x
.
shape
dim
=
len
(
sizes
)
if
dim
<
3
:
raise
ValueError
(
'Expected 3D or higher dimensionality input, but got {} dimensions'
.
format
(
dim
))
div
=
paddle
.
unsqueeze
(
paddle
.
multiply
(
x
,
x
),
axis
=
1
)
pad4d_shape
=
[
self
.
size
//
2
,
(
self
.
size
-
1
)
//
2
,
0
,
0
]
pool2d_shape
=
(
1
,
self
.
size
)
pad5d_shape
=
[
self
.
size
//
2
,
(
self
.
size
-
1
)
//
2
,
0
,
0
,
0
,
0
]
pool3d_shape
=
(
1
,
1
,
self
.
size
)
if
dim
==
3
:
div
=
paddle
.
nn
.
functional
.
pad
(
div
,
pad
=
pad4d_shape
)
div
=
paddle
.
nn
.
functional
.
avg_pool2d
(
div
,
kernel_size
=
pool2d_shape
,
stride
=
1
)
div
=
paddle
.
squeeze
(
div
,
axis
=
1
)
else
:
tmp
=
paddle
.
unsqueeze
(
x
,
axis
=
1
)
reshape_shape
=
paddle
.
shape
(
tmp
)
new_reshape_shape
=
paddle
.
cast
(
reshape_shape
,
"float32"
)
index
=
paddle
.
full
(
shape
=
[
1
],
fill_value
=-
2
,
dtype
=
"int32"
)
value
=
paddle
.
full
(
shape
=
[
1
],
fill_value
=-
1
,
dtype
=
"float32"
)
new_reshape_shape
=
paddle
.
scatter
(
new_reshape_shape
,
index
,
value
)
new_reshape_shape
=
paddle
.
cast
(
new_reshape_shape
,
"int32"
)
div
=
paddle
.
reshape
(
div
,
shape
=
reshape_shape
)
div
=
paddle
.
nn
.
functional
.
pad
(
div
,
pad
=
pad5d_shape
,
data_format
=
'NCDHW'
)
div
=
paddle
.
nn
.
functional
.
avg_pool3d
(
div
,
kernel_size
=
pool3d_shape
,
stride
=
1
)
div
=
paddle
.
reshape
(
paddle
.
squeeze
(
div
,
axis
=
1
),
sizes
)
div
=
paddle
.
scale
(
div
,
scale
=
self
.
alpha
,
bias
=
self
.
k
)
div
=
paddle
.
pow
(
div
,
self
.
beta
)
res
=
paddle
.
divide
(
x
,
div
)
return
res
x2paddle/op_mapper/onnx2paddle/opset9/opset.py
浏览文件 @
a20d95a7
...
...
@@ -2148,7 +2148,7 @@ class OpSet9():
size
=
node
.
get_attr
(
'size'
)
layer_attrs
=
{
'size'
:
size
,
'alpha'
:
alpha
,
'beta'
:
beta
,
'k'
:
bias
}
self
.
paddle_graph
.
add_layer
(
"
custom_layer:
LocalResponseNorm"
,
"
paddle.nn.
LocalResponseNorm"
,
inputs
=
{
"x"
:
val_x
.
name
},
outputs
=
layer_outputs
,
**
layer_attrs
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录