Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
models
提交
428b4ef3
M
models
项目概览
PaddlePaddle
/
models
接近 2 年 前同步成功
通知
230
Star
6828
Fork
2962
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
602
列表
看板
标记
里程碑
合并请求
255
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
models
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
602
Issue
602
列表
看板
标记
里程碑
合并请求
255
合并请求
255
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
428b4ef3
编写于
12月 11, 2018
作者:
R
Renwb1991
提交者:
qingqing01
12月 11, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
caffe2fluid:add power layer and fix bugs in priorbox and pool layers (#1508)
上级
5c9deb5e
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
66 addition
and
8 deletion
+66
-8
fluid/PaddleCV/caffe2fluid/kaffe/custom_layers/__init__.py
fluid/PaddleCV/caffe2fluid/kaffe/custom_layers/__init__.py
+1
-0
fluid/PaddleCV/caffe2fluid/kaffe/custom_layers/power.py
fluid/PaddleCV/caffe2fluid/kaffe/custom_layers/power.py
+40
-0
fluid/PaddleCV/caffe2fluid/kaffe/custom_layers/priorbox.py
fluid/PaddleCV/caffe2fluid/kaffe/custom_layers/priorbox.py
+7
-4
fluid/PaddleCV/caffe2fluid/kaffe/layers.py
fluid/PaddleCV/caffe2fluid/kaffe/layers.py
+1
-1
fluid/PaddleCV/caffe2fluid/kaffe/paddle/network.py
fluid/PaddleCV/caffe2fluid/kaffe/paddle/network.py
+13
-3
fluid/PaddleCV/caffe2fluid/kaffe/shapes.py
fluid/PaddleCV/caffe2fluid/kaffe/shapes.py
+4
-0
未找到文件。
fluid/PaddleCV/caffe2fluid/kaffe/custom_layers/__init__.py
浏览文件 @
428b4ef3
...
...
@@ -15,6 +15,7 @@ import detection_out
import
normalize
import
select
import
crop
import
power
import
reduction
#custom layer import ends
...
...
fluid/PaddleCV/caffe2fluid/kaffe/custom_layers/power.py
0 → 100644
浏览文件 @
428b4ef3
""" a custom layer for 'power', maybe we should implement this in standard way.
more info can be found here: http://caffe.berkeleyvision.org/tutorial/layers/power.html
"""
from
.register
import
register
def
power_shape
(
input_shape
,
shape
=
None
):
""" calculate the output shape of this layer using input shape
Args:
@input_shape (list of num): a list of number which represents the input shape
Returns:
@output_shape (list of num): a list of numbers represent the output shape
"""
return
input_shape
def
power_layer
(
input
,
name
,
power
=
1.0
,
scale
=
1.0
,
shift
=
0.0
):
""" build a layer of type 'Power' using fluid
Args:
@input (variables): input fluid variable for this layer
@name (str): name for this layer
@power (float): parameter from caffe's Power layer
@scale (float): parameter from caffe's Power layer
@shift (float): parameter from caffe's Power layer
Returns:
output (variable): output variable for this layer
"""
import
paddle.fluid
as
fluid
scale_out
=
fluid
.
layers
.
scale
(
input
,
scale
=
scale
,
bias
=
shift
,
bias_after_scale
=
True
)
output
=
fluid
.
layers
.
pow
(
scale_out
,
factor
=
power
)
return
output
register
(
kind
=
'Power'
,
shape
=
power_shape
,
layer
=
power_layer
)
fluid/PaddleCV/caffe2fluid/kaffe/custom_layers/priorbox.py
浏览文件 @
428b4ef3
...
...
@@ -31,12 +31,12 @@ def priorbox_shape(input_shapes, min_size, max_size=None, aspect_ratio=None):
def
priorbox_layer
(
inputs
,
name
,
min_size
,
step
,
max_size
=
None
,
aspect_ratio
=
None
,
flip
=
True
,
variance
=
[
0.1
,
0.1
,
0.2
,
0.2
],
flip
=
False
,
clip
=
False
,
variance
=
[]
,
step
=
0.0
,
offset
=
0.5
):
""" build a layer of type 'Priorbox' using fluid
...
...
@@ -52,6 +52,8 @@ def priorbox_layer(inputs,
assert
len
(
inputs
)
==
2
,
"invalid inputs for Priorbox[%s]"
%
(
name
)
input
=
inputs
[
0
]
image
=
inputs
[
1
]
steps
=
tuple
(
step
)
if
type
(
step
)
is
list
or
type
(
step
)
is
tuple
else
(
step
,
step
)
box
,
variance_
=
fluid
.
layers
.
prior_box
(
input
,
image
,
...
...
@@ -60,7 +62,8 @@ def priorbox_layer(inputs,
aspect_ratio
,
variance
,
flip
,
clip
,
(
step
,
step
),
clip
,
steps
,
offset
,
min_max_aspect_ratios_order
=
True
)
"""
...
...
fluid/PaddleCV/caffe2fluid/kaffe/layers.py
浏览文件 @
428b4ef3
...
...
@@ -38,7 +38,7 @@ LAYER_DESCRIPTORS = {
'MultinomialLogisticLoss'
:
shape_scalar
,
'MVN'
:
shape_not_implemented
,
'Pooling'
:
shape_pool
,
'Power'
:
shape_
identity
,
'Power'
:
shape_
power
,
'ReLU'
:
shape_identity
,
'PReLU'
:
shape_identity
,
'Scale'
:
shape_identity
,
...
...
fluid/PaddleCV/caffe2fluid/kaffe/paddle/network.py
浏览文件 @
428b4ef3
...
...
@@ -280,8 +280,17 @@ class Network(object):
param_attr
=
fluid
.
ParamAttr
(
name
=
prefix
+
'negslope'
))
return
output
def
pool
(
self
,
pool_type
,
input
,
k_h
,
k_w
,
s_h
,
s_w
,
ceil_mode
,
padding
,
name
):
def
pool
(
self
,
pool_type
,
input
,
k_h
,
k_w
,
s_h
,
s_w
,
ceil_mode
,
padding
,
name
,
exclusive
=
True
):
# Get the number of channels in the input
in_hw
=
input
.
shape
[
2
:]
k_hw
=
[
k_h
,
k_w
]
...
...
@@ -295,7 +304,8 @@ class Network(object):
pool_stride
=
s_hw
,
pool_padding
=
padding
,
ceil_mode
=
ceil_mode
,
pool_type
=
pool_type
)
pool_type
=
pool_type
,
exclusive
=
exclusive
)
return
output
@
layer
...
...
fluid/PaddleCV/caffe2fluid/kaffe/shapes.py
浏览文件 @
428b4ef3
...
...
@@ -67,6 +67,10 @@ def shape_crop(node):
raise
KaffeError
(
'crop function had been defined in customer_layers'
)
def
shape_power
(
node
):
raise
KaffeError
(
'power function had been defined in customer_layers'
)
def
shape_data
(
node
):
if
node
.
output_shape
:
# Old-style input specification
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录