Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Crayon鑫
Paddle
提交
55eb2fcf
P
Paddle
项目概览
Crayon鑫
/
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看板
提交
55eb2fcf
编写于
1月 26, 2017
作者:
H
Haonan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
format correction
上级
f5995300
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
45 addition
and
47 deletion
+45
-47
paddle/gserver/layers/RotateLayer.cpp
paddle/gserver/layers/RotateLayer.cpp
+26
-28
python/paddle/trainer/config_parser.py
python/paddle/trainer/config_parser.py
+0
-1
python/paddle/trainer_config_helpers/layers.py
python/paddle/trainer_config_helpers/layers.py
+17
-14
python/paddle/trainer_config_helpers/tests/layers_test_config.py
...paddle/trainer_config_helpers/tests/layers_test_config.py
+2
-4
未找到文件。
paddle/gserver/layers/RotateLayer.cpp
浏览文件 @
55eb2fcf
...
@@ -40,19 +40,17 @@ void RotateLayer::forward(PassType passType) {
...
@@ -40,19 +40,17 @@ void RotateLayer::forward(PassType passType) {
MatrixPtr
outV
=
getOutputValue
();
MatrixPtr
outV
=
getOutputValue
();
for
(
int
b
=
0
;
b
<
batchSize_
;
b
++
)
{
for
(
int
b
=
0
;
b
<
batchSize_
;
b
++
)
{
MatrixPtr
inputSample
MatrixPtr
inputSample
=
Matrix
::
create
(
input
->
getData
()
+
b
*
sampleSize_
,
=
Matrix
::
create
(
input
->
getData
()
+
b
*
sampleSize_
,
sampleHeight_
,
sampleHeight_
,
sampleWidth_
,
sampleWidth_
,
false
,
false
,
useGpu_
);
useGpu_
);
MatrixPtr
outputSample
=
Matrix
::
create
(
outV
->
getData
()
+
b
*
sampleSize_
,
MatrixPtr
outputSample
sampleWidth_
,
=
Matrix
::
create
(
outV
->
getData
()
+
b
*
sampleSize_
,
sampleHeight_
,
sampleWidth_
,
false
,
sampleHeight_
,
useGpu_
);
false
,
useGpu_
);
inputSample
->
rotate
(
outputSample
,
false
,
true
);
inputSample
->
rotate
(
outputSample
,
false
,
true
);
}
}
...
@@ -71,21 +69,21 @@ void RotateLayer::backward(const UpdateCallback& callback) {
...
@@ -71,21 +69,21 @@ void RotateLayer::backward(const UpdateCallback& callback) {
// the grad should be rotated in the reverse direction
// the grad should be rotated in the reverse direction
MatrixPtr
preGrad
=
getInputGrad
(
0
);
MatrixPtr
preGrad
=
getInputGrad
(
0
);
for
(
int
b
=
0
;
b
<
batchSize_
;
b
++
)
{
for
(
int
b
=
0
;
b
<
batchSize_
;
b
++
)
{
MatrixPtr
inputSampleGrad
MatrixPtr
inputSampleGrad
=
=
Matrix
::
create
(
preGrad
->
getData
()
+
b
*
sampleSize_
,
Matrix
::
create
(
preGrad
->
getData
()
+
b
*
sampleSize_
,
sampleHeight_
,
sampleHeight_
,
sampleWidth_
,
sampleWidth_
,
false
,
false
,
useGpu_
);
useGpu_
);
MatrixPtr
outputSampleGrad
MatrixPtr
outputSampleGrad
=
=
Matrix
::
create
(
outputGrad
->
getData
()
+
b
*
sampleSize_
,
Matrix
::
create
(
outputGrad
->
getData
()
+
b
*
sampleSize_
,
sampleWidth_
,
sampleWidth_
,
sampleHeight_
,
sampleHeight_
,
false
,
false
,
useGpu_
);
useGpu_
);
MatrixPtr
tmpGrad
MatrixPtr
tmpGrad
=
=
Matrix
::
create
(
sampleHeight_
,
sampleWidth_
,
false
,
useGpu_
);
Matrix
::
create
(
sampleHeight_
,
sampleWidth_
,
false
,
useGpu_
);
outputSampleGrad
->
rotate
(
tmpGrad
,
false
,
false
);
outputSampleGrad
->
rotate
(
tmpGrad
,
false
,
false
);
inputSampleGrad
->
add
(
*
tmpGrad
);
inputSampleGrad
->
add
(
*
tmpGrad
);
}
}
...
...
python/paddle/trainer/config_parser.py
浏览文件 @
55eb2fcf
...
@@ -1833,7 +1833,6 @@ class PoolLayer(LayerBase):
...
@@ -1833,7 +1833,6 @@ class PoolLayer(LayerBase):
pool_conf
.
channels
)
pool_conf
.
channels
)
@
config_layer
(
'spp'
)
@
config_layer
(
'spp'
)
class
SpatialPyramidPoolLayer
(
LayerBase
):
class
SpatialPyramidPoolLayer
(
LayerBase
):
def
__init__
(
self
,
name
,
inputs
,
**
xargs
):
def
__init__
(
self
,
name
,
inputs
,
**
xargs
):
...
...
python/paddle/trainer_config_helpers/layers.py
浏览文件 @
55eb2fcf
...
@@ -1707,15 +1707,17 @@ def rotate_layer(input, height, name=None, layer_attr=None):
...
@@ -1707,15 +1707,17 @@ def rotate_layer(input, height, name=None, layer_attr=None):
:rtype: LayerOutput
:rtype: LayerOutput
"""
"""
assert
isinstance
(
input
,
LayerOutput
)
assert
isinstance
(
input
,
LayerOutput
)
l
=
Layer
(
name
=
name
,
l
=
Layer
(
height
=
height
,
name
=
name
,
type
=
LayerType
.
ROTATE_LAYER
,
height
=
height
,
inputs
=
[
input
.
name
],
type
=
LayerType
.
ROTATE_LAYER
,
**
ExtraLayerAttribute
.
to_kwargs
(
layer_attr
))
inputs
=
[
input
.
name
],
return
LayerOutput
(
name
=
name
,
**
ExtraLayerAttribute
.
to_kwargs
(
layer_attr
))
layer_type
=
LayerType
.
ROTATE_LAYER
,
return
LayerOutput
(
parents
=
[
input
],
name
=
name
,
size
=
l
.
config
.
size
)
layer_type
=
LayerType
.
ROTATE_LAYER
,
parents
=
[
input
],
size
=
l
.
config
.
size
)
@
wrap_name_default
()
@
wrap_name_default
()
...
@@ -1750,11 +1752,12 @@ def flip_layer(input, height, name=None, layer_attr=None):
...
@@ -1750,11 +1752,12 @@ def flip_layer(input, height, name=None, layer_attr=None):
:rtype: LayerOutput
:rtype: LayerOutput
"""
"""
assert
isinstance
(
input
,
LayerOutput
)
assert
isinstance
(
input
,
LayerOutput
)
return
rotate_layer
(
input
=
rotate_layer
(
input
=
input
,
return
rotate_layer
(
height
=
height
),
input
=
rotate_layer
(
height
=
height
,
input
=
input
,
height
=
height
),
name
=
name
,
height
=
height
,
layer_attr
=
layer_attr
)
name
=
name
,
layer_attr
=
layer_attr
)
@
wrap_name_default
()
@
wrap_name_default
()
...
...
python/paddle/trainer_config_helpers/tests/layers_test_config.py
浏览文件 @
55eb2fcf
...
@@ -39,10 +39,8 @@ z1 = mixed_layer(
...
@@ -39,10 +39,8 @@ z1 = mixed_layer(
assert
z1
.
size
>
0
assert
z1
.
size
>
0
y2
=
fc_layer
(
input
=
y
,
size
=
15
)
y2
=
fc_layer
(
input
=
y
,
size
=
15
)
z2
=
rotate_layer
(
input
=
y2
,
z2
=
rotate_layer
(
input
=
y2
,
height
=
5
)
height
=
5
)
z3
=
flip_layer
(
input
=
y2
,
height
=
3
)
z3
=
flip_layer
(
input
=
y2
,
height
=
3
)
cos1
=
cos_sim
(
a
=
x1
,
b
=
y1
)
cos1
=
cos_sim
(
a
=
x1
,
b
=
y1
)
cos3
=
cos_sim
(
a
=
x1
,
b
=
y2
,
size
=
3
)
cos3
=
cos_sim
(
a
=
x1
,
b
=
y2
,
size
=
3
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录