Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
1906e63f
P
Paddle
项目概览
BaiXuePrincess
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
1906e63f
编写于
11月 14, 2017
作者:
X
xzl
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix prelu(add filter_num output_x output_y) and add channel_shared param
上级
93c6e52a
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
30 addition
and
3 deletion
+30
-3
python/paddle/trainer/config_parser.py
python/paddle/trainer/config_parser.py
+7
-1
python/paddle/trainer_config_helpers/layers.py
python/paddle/trainer_config_helpers/layers.py
+23
-2
未找到文件。
python/paddle/trainer/config_parser.py
浏览文件 @
1906e63f
...
@@ -2052,9 +2052,15 @@ class ParameterReluLayer(LayerBase):
...
@@ -2052,9 +2052,15 @@ class ParameterReluLayer(LayerBase):
config_assert
(
len
(
self
.
inputs
)
==
1
,
"prelu layer has only one input."
)
config_assert
(
len
(
self
.
inputs
)
==
1
,
"prelu layer has only one input."
)
config_assert
(
input_layer
.
size
%
partial_sum
==
0
,
config_assert
(
input_layer
.
size
%
partial_sum
==
0
,
"a wrong setting for partial_sum"
)
"a wrong setting for partial_sum"
)
dims
=
[
1
,
input_layer
.
size
/
partial_sum
]
self
.
set_layer_size
(
input_layer
.
size
)
self
.
set_layer_size
(
input_layer
.
size
)
self
.
config
.
partial_sum
=
partial_sum
self
.
config
.
partial_sum
=
partial_sum
self
.
create_input_parameter
(
0
,
input_layer
.
size
/
partial_sum
)
self
.
create_input_parameter
(
0
,
input_layer
.
size
/
partial_sum
,
dims
)
self
.
set_layer_height_width
(
self
.
get_input_layer
(
0
).
height
,
\
self
.
get_input_layer
(
0
).
width
)
self
.
set_layer_depth
(
self
.
get_input_layer
(
0
).
depth
)
@
config_layer
(
'conv'
)
@
config_layer
(
'conv'
)
...
...
python/paddle/trainer_config_helpers/layers.py
浏览文件 @
1906e63f
...
@@ -6393,10 +6393,11 @@ def row_conv_layer(input,
...
@@ -6393,10 +6393,11 @@ def row_conv_layer(input,
@
layer_support
()
@
layer_support
()
@
wrap_name_default
()
@
wrap_name_default
()
@
wrap_param_attr_default
()
def
prelu_layer
(
input
,
def
prelu_layer
(
input
,
name
=
None
,
name
=
None
,
partial_sum
=
1
,
partial_sum
=
1
,
channel_shared
=
None
,
num_channels
=
None
,
param_attr
=
None
,
param_attr
=
None
,
layer_attr
=
None
):
layer_attr
=
None
):
"""
"""
...
@@ -6427,6 +6428,10 @@ def prelu_layer(input,
...
@@ -6427,6 +6428,10 @@ def prelu_layer(input,
- partial_sum = number of outputs, indicates all elements share the same weight.
- partial_sum = number of outputs, indicates all elements share the same weight.
:type partial_sum: int
:type partial_sum: int
:param channel_shared: whether or not the parameter are shared across channels.
- channel_shared = True, we set the partial_sum to the number of outputs.
- channel_shared = False, we set the partial_sum to the number of elements in one channel.
:type channel_shared: bool
:param param_attr: The parameter attribute. See ParameterAttribute for details.
:param param_attr: The parameter attribute. See ParameterAttribute for details.
:type param_attr: ParameterAttribute
:type param_attr: ParameterAttribute
:param layer_attr: The extra layer attribute. See ExtraLayerAttribute for
:param layer_attr: The extra layer attribute. See ExtraLayerAttribute for
...
@@ -6437,8 +6442,23 @@ def prelu_layer(input,
...
@@ -6437,8 +6442,23 @@ def prelu_layer(input,
"""
"""
assert
isinstance
(
input
,
LayerOutput
),
'prelu_layer accepts only one input.'
assert
isinstance
(
input
,
LayerOutput
),
'prelu_layer accepts only one input.'
if
not
param_attr
:
param_attr
=
ParamAttr
(
initial_mean
=
0.25
,
initial_std
=
0.0
)
else
:
assert
isinstance
(
param_attr
,
ParameterAttribute
)
assert
isinstance
(
param_attr
,
ParameterAttribute
)
if
num_channels
is
None
:
assert
input
.
num_filters
is
not
None
num_channels
=
input
.
num_filters
if
channel_shared
is
not
None
:
assert
isinstance
(
channel_shared
,
bool
)
if
channel_shared
:
partial_sum
=
input
.
height
*
input
.
width
*
num_channels
else
:
partial_sum
=
input
.
height
*
input
.
width
l
=
Layer
(
l
=
Layer
(
name
=
name
,
name
=
name
,
type
=
LayerType
.
PRELU
,
type
=
LayerType
.
PRELU
,
...
@@ -6449,6 +6469,7 @@ def prelu_layer(input,
...
@@ -6449,6 +6469,7 @@ def prelu_layer(input,
name
=
name
,
name
=
name
,
layer_type
=
LayerType
.
PRELU
,
layer_type
=
LayerType
.
PRELU
,
parents
=
input
,
parents
=
input
,
num_filters
=
num_channels
,
size
=
l
.
config
.
size
)
size
=
l
.
config
.
size
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录