Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
机器未来
Paddle
提交
d7b80f03
P
Paddle
项目概览
机器未来
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
d7b80f03
编写于
8月 02, 2017
作者:
X
xuwei06
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Correctly handle width and height for some layers
上级
0d1715da
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
30 addition
and
10 deletion
+30
-10
python/paddle/trainer/config_parser.py
python/paddle/trainer/config_parser.py
+7
-4
python/paddle/trainer_config_helpers/layers.py
python/paddle/trainer_config_helpers/layers.py
+23
-6
未找到文件。
python/paddle/trainer/config_parser.py
浏览文件 @
d7b80f03
...
...
@@ -338,7 +338,8 @@ def RecurrentLayerGroupWithoutOutLinksBegin(name,
in_links_count
+=
1
layer_name
=
MakeLayerNameInParentSubmodel
(
name
)
layer
=
g_layer_map
[
layer_name
]
ScatterAgentLayer
(
name
=
name
,
size
=
layer
.
size
)
ScatterAgentLayer
(
name
=
name
,
size
=
layer
.
size
,
width
=
layer
.
width
,
height
=
layer
.
height
)
pair
=
g_current_submodel
.
in_links
.
add
()
pair
.
layer_name
=
layer_name
...
...
@@ -2197,8 +2198,8 @@ class MaxOutLayer(LayerBase):
maxout_conf
=
self
.
config
.
inputs
[
0
].
maxout_conf
parse_maxout
(
self
.
inputs
[
0
].
maxout
,
input_layer
.
name
,
maxout_conf
)
out_channels
=
maxout_conf
.
image_conf
.
channels
/
maxout_conf
.
groups
self
.
set_cnn_layer
(
name
,
g_layer_map
[
input_layer
.
name
].
height
,
g_layer_map
[
input_layer
.
name
].
width
,
out_channels
)
self
.
set_cnn_layer
(
name
,
maxout_conf
.
image_conf
.
img_size_y
,
maxout_conf
.
image_conf
.
img_size
,
out_channels
)
@
config_layer
(
'row_conv'
)
...
...
@@ -2405,9 +2406,11 @@ class GatherAgentLayer(LayerBase):
@
config_layer
(
'scatter_agent'
)
class
ScatterAgentLayer
(
LayerBase
):
def
__init__
(
self
,
name
,
size
,
device
=
None
):
def
__init__
(
self
,
name
,
size
,
width
=
None
,
height
=
None
,
device
=
None
):
super
(
ScatterAgentLayer
,
self
).
__init__
(
name
,
'scatter_agent'
,
size
,
inputs
=
[],
device
=
device
)
if
height
and
width
:
self
.
set_layer_height_width
(
height
,
width
)
@
config_layer
(
'multiplex'
)
...
...
python/paddle/trainer_config_helpers/layers.py
浏览文件 @
d7b80f03
...
...
@@ -16,11 +16,13 @@ import functools
import
collections
import
inspect
import
paddle.trainer.config_parser
as
cp
from
paddle.trainer.config_parser
import
*
from
.activations
import
LinearActivation
,
SigmoidActivation
,
TanhActivation
,
\
ReluActivation
,
IdentityActivation
,
SoftmaxActivation
,
BaseActivation
from
.evaluators
import
*
from
.poolings
import
MaxPooling
,
AvgPooling
,
BasePoolingType
from
.poolings
import
MaxPooling
,
AvgPooling
,
BasePoolingType
,
\
CudnnAvgPooling
,
CudnnMaxPooling
from
.attrs
import
*
from
.default_decorators
import
*
...
...
@@ -330,6 +332,14 @@ class LayerOutput(object):
self
.
outputs
=
outputs
self
.
reverse
=
reverse
@
property
def
width
(
self
):
return
cp
.
g_layer_map
[
self
.
full_name
].
width
@
property
def
height
(
self
):
return
cp
.
g_layer_map
[
self
.
full_name
].
height
def
set_input
(
self
,
input
):
"""
Set the input for a memory layer. Can only be used for memory layer
...
...
@@ -911,7 +921,13 @@ def data_layer(name, size, height=None, width=None, layer_attr=None):
width
=
width
,
**
ExtraLayerAttribute
.
to_kwargs
(
layer_attr
))
return
LayerOutput
(
name
,
LayerType
.
DATA
,
size
=
size
)
num_filters
=
None
if
height
is
not
None
and
width
is
not
None
:
num_filters
=
size
/
(
width
*
height
)
assert
num_filters
*
width
*
height
==
size
,
\
"size=%s width=%s height=%s"
%
(
size
,
width
,
height
)
return
LayerOutput
(
name
,
LayerType
.
DATA
,
size
=
size
,
num_filters
=
num_filters
)
@
wrap_name_default
(
"embedding"
)
...
...
@@ -2571,6 +2587,10 @@ def img_pool_layer(input,
assert
input
.
num_filters
is
not
None
num_channels
=
input
.
num_filters
assert
type
(
pool_type
)
in
[
AvgPooling
,
MaxPooling
,
CudnnAvgPooling
,
CudnnMaxPooling
],
\
"only AvgPooling and MaxPooling are supported"
if
pool_type
is
None
:
pool_type
=
MaxPooling
()
elif
isinstance
(
pool_type
,
AvgPooling
):
...
...
@@ -2580,7 +2600,6 @@ def img_pool_layer(input,
if
(
isinstance
(
pool_type
,
AvgPooling
)
or
isinstance
(
pool_type
,
MaxPooling
))
\
else
pool_type
.
name
pool_size_y
=
pool_size
if
pool_size_y
is
None
else
pool_size_y
stride_y
=
stride
if
stride_y
is
None
else
stride_y
padding_y
=
padding
if
padding_y
is
None
else
padding_y
...
...
@@ -4204,8 +4223,7 @@ def conv_operator(img,
num_channels
=
img
.
num_filters
assert
isinstance
(
filter
,
LayerOutput
)
if
filter
.
size
is
not
None
:
filter
.
size
=
filter_size
*
filter_size_y
*
num_filters
*
num_channels
assert
filter
.
size
is
not
None
opCls
=
ConvTransOperator
if
trans
else
ConvOperator
...
...
@@ -4916,7 +4934,6 @@ def maxout_layer(input, groups, num_channels=None, name=None, layer_attr=None):
:return: LayerOutput object.
:rtype: LayerOutput
"""
assert
input
.
layer_type
==
LayerType
.
CONV_LAYER
assert
isinstance
(
input
.
activation
,
LinearActivation
)
assert
groups
>
1
if
num_channels
is
None
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录