Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
6da00da7
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2298
Star
20931
Fork
5422
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
6da00da7
编写于
11月 20, 2017
作者:
X
xzl
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
code format check
上级
7dc584f5
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
192 addition
and
182 deletion
+192
-182
paddle/cuda/include/hl_cnn.h
paddle/cuda/include/hl_cnn.h
+18
-16
paddle/cuda/include/stub/hl_cnn_stub.h
paddle/cuda/include/stub/hl_cnn_stub.h
+19
-17
paddle/gserver/layers/UpsampleLayer.cpp
paddle/gserver/layers/UpsampleLayer.cpp
+1
-0
paddle/gserver/layers/UpsampleLayer.h
paddle/gserver/layers/UpsampleLayer.h
+0
-1
paddle/math/Matrix.cpp
paddle/math/Matrix.cpp
+110
-110
paddle/math/Matrix.h
paddle/math/Matrix.h
+36
-36
python/paddle/trainer/config_parser.py
python/paddle/trainer/config_parser.py
+6
-2
python/paddle/trainer_config_helpers/layers.py
python/paddle/trainer_config_helpers/layers.py
+2
-0
未找到文件。
paddle/cuda/include/hl_cnn.h
浏览文件 @
6da00da7
...
@@ -378,14 +378,15 @@ extern void hl_maxout_backward(real* inGrad,
...
@@ -378,14 +378,15 @@ extern void hl_maxout_backward(real* inGrad,
* @param[in] outputW the output widht.
* @param[in] outputW the output widht.
* @param[out] outputData output data.
* @param[out] outputData output data.
*/
*/
extern
void
hl_upsample_forward
(
real
*
inputData
,
real
*
maskData
,
extern
void
hl_upsample_forward
(
real
*
inputData
,
size_t
batchSize
,
real
*
maskData
,
size_t
imgSizeH
,
size_t
batchSize
,
size_t
imgSizeW
,
size_t
imgSizeH
,
size_t
channels
,
size_t
imgSizeW
,
size_t
outputH
,
size_t
channels
,
size_t
outputW
,
size_t
outputH
,
real
*
outputData
);
size_t
outputW
,
real
*
outputData
);
/**
/**
* @brief Upsample backward.
* @brief Upsample backward.
...
@@ -399,13 +400,14 @@ extern void hl_upsample_forward(real *inputData, real *maskData,
...
@@ -399,13 +400,14 @@ extern void hl_upsample_forward(real *inputData, real *maskData,
* @param[in] outputW the output widht.
* @param[in] outputW the output widht.
* @param[out] inputGradData the input grad data.
* @param[out] inputGradData the input grad data.
*/
*/
extern
void
hl_upsample_backward
(
real
*
outputGradData
,
real
*
maskData
,
extern
void
hl_upsample_backward
(
real
*
outputGradData
,
size_t
batchSize
,
real
*
maskData
,
size_t
imgSizeH
,
size_t
batchSize
,
size_t
imgSizeW
,
size_t
imgSizeH
,
size_t
channels
,
size_t
imgSizeW
,
size_t
outputH
,
size_t
channels
,
size_t
outputW
,
size_t
outputH
,
real
*
inputGradData
);
size_t
outputW
,
real
*
inputGradData
);
#endif // HL_CNN_H_
#endif // HL_CNN_H_
paddle/cuda/include/stub/hl_cnn_stub.h
浏览文件 @
6da00da7
...
@@ -222,22 +222,24 @@ inline void hl_maxout_backward(real* inGrad,
...
@@ -222,22 +222,24 @@ inline void hl_maxout_backward(real* inGrad,
size_t
featLen
,
size_t
featLen
,
size_t
group
)
{}
size_t
group
)
{}
inline
void
hl_upsample_forward
(
real
*
inputData
,
real
*
maskData
,
inline
void
hl_upsample_forward
(
real
*
inputData
,
size_t
batchSize
,
real
*
maskData
,
size_t
imgSizeH
,
size_t
batchSize
,
size_t
imgSizeW
,
size_t
imgSizeH
,
size_t
channels
,
size_t
imgSizeW
,
size_t
outputH
,
size_t
channels
,
size_t
outputW
,
size_t
outputH
,
real
*
outputData
)
{}
size_t
outputW
,
real
*
outputData
)
{}
inline
void
hl_upsample_backward
(
real
*
outputGradData
,
real
*
maskData
,
size_t
batchSize
,
inline
void
hl_upsample_backward
(
real
*
outputGradData
,
size_t
imgSizeH
,
real
*
maskData
,
size_t
imgSizeW
,
size_t
batchSize
,
size_t
channels
,
size_t
imgSizeH
,
size_t
outputH
,
size_t
imgSizeW
,
size_t
outputW
,
size_t
channels
,
real
*
inputGradData
)
{}
size_t
outputH
,
size_t
outputW
,
real
*
inputGradData
)
{}
#endif // HL_CNN_STUB_H_
#endif // HL_CNN_STUB_H_
paddle/gserver/layers/UpsampleLayer.cpp
浏览文件 @
6da00da7
...
@@ -30,6 +30,7 @@ size_t UpsampleLayer::getOutputSize() {
...
@@ -30,6 +30,7 @@ size_t UpsampleLayer::getOutputSize() {
bool
UpsampleLayer
::
init
(
const
LayerMap
&
layerMap
,
bool
UpsampleLayer
::
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
{
const
ParameterMap
&
parameterMap
)
{
Layer
::
init
(
layerMap
,
parameterMap
);
Layer
::
init
(
layerMap
,
parameterMap
);
CHECK_EQ
(
inputLayers_
.
size
(),
2U
);
CHECK_EQ
(
inputLayers_
.
size
(),
2U
);
CHECK_EQ
(
config_
.
inputs_size
(),
2
);
CHECK_EQ
(
config_
.
inputs_size
(),
2
);
const
auto
&
conf
=
config_
.
inputs
(
0
).
upsample_conf
();
const
auto
&
conf
=
config_
.
inputs
(
0
).
upsample_conf
();
...
...
paddle/gserver/layers/UpsampleLayer.h
浏览文件 @
6da00da7
...
@@ -32,7 +32,6 @@ namespace paddle {
...
@@ -32,7 +32,6 @@ namespace paddle {
class
UpsampleLayer
:
public
Layer
{
class
UpsampleLayer
:
public
Layer
{
public:
public:
explicit
UpsampleLayer
(
const
LayerConfig
&
config
)
:
Layer
(
config
)
{}
explicit
UpsampleLayer
(
const
LayerConfig
&
config
)
:
Layer
(
config
)
{}
~
UpsampleLayer
()
{}
~
UpsampleLayer
()
{}
bool
init
(
const
LayerMap
&
layerMap
,
bool
init
(
const
LayerMap
&
layerMap
,
...
...
paddle/math/Matrix.cpp
浏览文件 @
6da00da7
...
@@ -1024,61 +1024,63 @@ void GpuMatrix::check(std::ostream& os, Matrix& refMat, bool printDiff) {
...
@@ -1024,61 +1024,63 @@ void GpuMatrix::check(std::ostream& os, Matrix& refMat, bool printDiff) {
}
}
void
GpuMatrix
::
upsampleForward
(
Matrix
&
input
,
void
GpuMatrix
::
upsampleForward
(
Matrix
&
input
,
Matrix
&
mask
,
Matrix
&
mask
,
size_t
imgSizeH
,
size_t
imgSizeH
,
size_t
imgSizeW
,
size_t
imgSizeW
,
size_t
channels
,
size_t
channels
,
size_t
outputH
,
size_t
outputH
,
size_t
outputW
)
{
size_t
outputW
)
{
CHECK
(
input
.
useGpu_
==
true
)
<<
"Matrix type are not equal"
;
CHECK
(
input
.
useGpu_
==
true
)
<<
"Matrix type are not equal"
;
CHECK
(
mask
.
useGpu_
==
true
)
<<
"Matrix type are not equal"
;
CHECK
(
mask
.
useGpu_
==
true
)
<<
"Matrix type are not equal"
;
real
*
inputData
=
input
.
getData
();
real
*
inputData
=
input
.
getData
();
real
*
maskData
=
mask
.
getData
();
real
*
maskData
=
mask
.
getData
();
real
*
outData
=
data_
;
real
*
outData
=
data_
;
size_t
batch
=
input
.
getHeight
();
size_t
batch
=
input
.
getHeight
();
CHECK
(
imgSizeH
*
imgSizeW
*
channels
==
input
.
getWidth
());
CHECK
(
imgSizeH
*
imgSizeW
*
channels
==
input
.
getWidth
());
CHECK
(
imgSizeH
*
imgSizeW
*
channels
==
mask
.
getWidth
());
CHECK
(
imgSizeH
*
imgSizeW
*
channels
==
mask
.
getWidth
());
CHECK_EQ
(
batch
,
this
->
getHeight
());
CHECK_EQ
(
batch
,
this
->
getHeight
());
CHECK
(
width_
==
outputH
*
outputW
*
channels
);
CHECK
(
width_
==
outputH
*
outputW
*
channels
);
hl_upsample_forward
(
inputData
,
maskData
,
hl_upsample_forward
(
inputData
,
batch
,
maskData
,
imgSizeH
,
batch
,
imgSizeW
,
imgSizeH
,
channels
,
imgSizeW
,
outputH
,
channels
,
outputW
,
outputH
,
outData
);
outputW
,
outData
);
}
}
void
GpuMatrix
::
upsampleBackward
(
Matrix
&
outputGrad
,
void
GpuMatrix
::
upsampleBackward
(
Matrix
&
outputGrad
,
Matrix
&
mask
,
Matrix
&
mask
,
size_t
imgSizeH
,
size_t
imgSizeH
,
size_t
imgSizeW
,
size_t
imgSizeW
,
size_t
channels
,
size_t
channels
,
size_t
outputH
,
size_t
outputH
,
size_t
outputW
)
{
size_t
outputW
)
{
CHECK
(
outputGrad
.
useGpu_
==
true
)
<<
"Matrix type are not equal"
;
CHECK
(
outputGrad
.
useGpu_
==
true
)
<<
"Matrix type are not equal"
;
CHECK
(
mask
.
useGpu_
==
true
)
<<
"Matrix type are not equal"
;
CHECK
(
mask
.
useGpu_
==
true
)
<<
"Matrix type are not equal"
;
real
*
outputGradData
=
outputGrad
.
getData
();
real
*
outputGradData
=
outputGrad
.
getData
();
real
*
maskData
=
mask
.
getData
();
real
*
maskData
=
mask
.
getData
();
real
*
inputGradData
=
data_
;
real
*
inputGradData
=
data_
;
size_t
batch
=
outputGrad
.
getHeight
();
size_t
batch
=
outputGrad
.
getHeight
();
CHECK
(
imgSizeH
*
imgSizeW
==
this
->
getWidth
()
/
channels
);
CHECK
(
imgSizeH
*
imgSizeW
==
this
->
getWidth
()
/
channels
);
CHECK_EQ
(
batch
,
this
->
getHeight
());
CHECK_EQ
(
batch
,
this
->
getHeight
());
CHECK_EQ
(
channels
*
outputH
*
outputW
,
outputGrad
.
getWidth
());
CHECK_EQ
(
channels
*
outputH
*
outputW
,
outputGrad
.
getWidth
());
hl_upsample_backward
(
outputGradData
,
maskData
,
hl_upsample_backward
(
outputGradData
,
batch
,
maskData
,
imgSizeH
,
batch
,
imgSizeW
,
imgSizeH
,
channels
,
imgSizeW
,
outputH
,
channels
,
outputW
,
outputH
,
inputGradData
);
outputW
,
inputGradData
);
}
}
void
GpuMatrix
::
maxPoolForward
(
Matrix
&
inputMat
,
void
GpuMatrix
::
maxPoolForward
(
Matrix
&
inputMat
,
...
@@ -2040,71 +2042,69 @@ void CpuMatrix::inverse(MatrixPtr& matInv, bool memAlloc) {
...
@@ -2040,71 +2042,69 @@ void CpuMatrix::inverse(MatrixPtr& matInv, bool memAlloc) {
}
}
void
CpuMatrix
::
upsampleForward
(
Matrix
&
input
,
void
CpuMatrix
::
upsampleForward
(
Matrix
&
input
,
Matrix
&
mask
,
Matrix
&
mask
,
size_t
imgSizeH
,
size_t
imgSizeH
,
size_t
imgSizeW
,
size_t
imgSizeW
,
size_t
channels
,
size_t
channels
,
size_t
outputH
,
size_t
outputH
,
size_t
outputW
)
{
size_t
outputW
)
{
real
*
inputData
=
input
.
getData
();
real
*
inputData
=
input
.
getData
();
real
*
maskData
=
mask
.
getData
();
real
*
maskData
=
mask
.
getData
();
real
*
outData
=
data_
;
real
*
outData
=
data_
;
size_t
inLength
=
imgSizeH
*
imgSizeW
;
size_t
inLength
=
imgSizeH
*
imgSizeW
;
size_t
outLength
=
outputH
*
outputW
;
size_t
outLength
=
outputH
*
outputW
;
size_t
batch
=
input
.
getHeight
();
size_t
batch
=
input
.
getHeight
();
CHECK
(
inLength
==
input
.
getWidth
()
/
channels
);
CHECK
(
inLength
==
input
.
getWidth
()
/
channels
);
CHECK_EQ
(
batch
,
this
->
getHeight
());
CHECK_EQ
(
batch
,
this
->
getHeight
());
CHECK_EQ
(
channels
*
outLength
,
this
->
getWidth
());
CHECK_EQ
(
channels
*
outLength
,
this
->
getWidth
());
for
(
size_t
k
=
0
;
k
<
batch
;
k
++
)
{
for
(
size_t
k
=
0
;
k
<
batch
;
k
++
)
{
for
(
size_t
c
=
0
;
c
<
channels
;
c
++
)
{
for
(
size_t
c
=
0
;
c
<
channels
;
c
++
)
{
for
(
size_t
i
=
0
;
i
<
inLength
;
i
++
)
{
for
(
size_t
i
=
0
;
i
<
inLength
;
i
++
)
{
size_t
out_index
=
static_cast
<
int
>
(
maskData
[
i
]);
size_t
out_index
=
static_cast
<
int
>
(
maskData
[
i
]);
if
(
out_index
>=
outLength
)
{
if
(
out_index
>=
outLength
)
{
LOG
(
FATAL
)
<<
"upsample index "
<<
out_index
LOG
(
FATAL
)
<<
"upsample index "
<<
out_index
<<
" out of range."
;
<<
" out of range."
;
}
outData
[
out_index
]
=
inputData
[
i
];
}
inputData
+=
inLength
;
maskData
+=
inLength
;
outData
+=
outLength
;
}
}
outData
[
out_index
]
=
inputData
[
i
];
}
inputData
+=
inLength
;
maskData
+=
inLength
;
outData
+=
outLength
;
}
}
}
}
}
void
CpuMatrix
::
upsampleBackward
(
Matrix
&
outputGrad
,
void
CpuMatrix
::
upsampleBackward
(
Matrix
&
outputGrad
,
Matrix
&
mask
,
Matrix
&
mask
,
size_t
imgSizeH
,
size_t
imgSizeH
,
size_t
imgSizeW
,
size_t
imgSizeW
,
size_t
channels
,
size_t
channels
,
size_t
outputH
,
size_t
outputH
,
size_t
outputW
)
{
size_t
outputW
)
{
real
*
outputGradData
=
outputGrad
.
getData
();
real
*
outputGradData
=
outputGrad
.
getData
();
real
*
maskData
=
mask
.
getData
();
real
*
maskData
=
mask
.
getData
();
real
*
inputGradData
=
data_
;
real
*
inputGradData
=
data_
;
size_t
inLength
=
imgSizeH
*
imgSizeW
;
size_t
inLength
=
imgSizeH
*
imgSizeW
;
size_t
outLength
=
outputH
*
outputW
;
size_t
outLength
=
outputH
*
outputW
;
size_t
batch
=
outputGrad
.
getHeight
();
size_t
batch
=
outputGrad
.
getHeight
();
CHECK
(
inLength
==
this
->
getWidth
()
/
channels
);
CHECK
(
inLength
==
this
->
getWidth
()
/
channels
);
CHECK_EQ
(
batch
,
this
->
getHeight
());
CHECK_EQ
(
batch
,
this
->
getHeight
());
CHECK_EQ
(
channels
*
outLength
,
outputGrad
.
getWidth
());
CHECK_EQ
(
channels
*
outLength
,
outputGrad
.
getWidth
());
for
(
size_t
k
=
0
;
k
<
batch
;
k
++
)
{
for
(
size_t
k
=
0
;
k
<
batch
;
k
++
)
{
for
(
size_t
c
=
0
;
c
<
channels
;
c
++
)
{
for
(
size_t
c
=
0
;
c
<
channels
;
c
++
)
{
for
(
size_t
i
=
0
;
i
<
inLength
;
i
++
)
{
for
(
size_t
i
=
0
;
i
<
inLength
;
i
++
)
{
size_t
out_index
=
static_cast
<
int
>
(
maskData
[
i
]);
size_t
out_index
=
static_cast
<
int
>
(
maskData
[
i
]);
if
(
out_index
>=
outLength
)
{
if
(
out_index
>=
outLength
)
{
LOG
(
FATAL
)
<<
"upsample index "
<<
out_index
LOG
(
FATAL
)
<<
"upsample index "
<<
out_index
<<
" out of range."
;
<<
" out of range."
;
}
inputGradData
[
i
]
=
outputGradData
[
out_index
];
}
inputGradData
+=
inLength
;
maskData
+=
inLength
;
outputGradData
+=
outLength
;
}
}
inputGradData
[
i
]
=
outputGradData
[
out_index
];
}
inputGradData
+=
inLength
;
maskData
+=
inLength
;
outputGradData
+=
outLength
;
}
}
}
}
}
void
CpuMatrix
::
maxPoolForward
(
Matrix
&
inputMat
,
void
CpuMatrix
::
maxPoolForward
(
Matrix
&
inputMat
,
...
...
paddle/math/Matrix.h
浏览文件 @
6da00da7
...
@@ -860,22 +860,22 @@ public:
...
@@ -860,22 +860,22 @@ public:
}
}
virtual
void
upsampleForward
(
Matrix
&
input
,
virtual
void
upsampleForward
(
Matrix
&
input
,
Matrix
&
mask
,
Matrix
&
mask
,
size_t
imgSizeH
,
size_t
imgSizeH
,
size_t
imgSizeW
,
size_t
imgSizeW
,
size_t
channels
,
size_t
channels
,
size_t
outputH
,
size_t
outputH
,
size_t
outputW
)
{
size_t
outputW
)
{
LOG
(
FATAL
)
<<
"Not implemeted"
;
LOG
(
FATAL
)
<<
"Not implemeted"
;
}
}
virtual
void
upsampleBackward
(
Matrix
&
outputGrad
,
virtual
void
upsampleBackward
(
Matrix
&
outputGrad
,
Matrix
&
mask
,
Matrix
&
mask
,
size_t
imgSizeH
,
size_t
imgSizeH
,
size_t
imgSizeW
,
size_t
imgSizeW
,
size_t
channels
,
size_t
channels
,
size_t
outputH
,
size_t
outputH
,
size_t
outputW
)
{
size_t
outputW
)
{
LOG
(
FATAL
)
<<
"Not implemeted"
;
LOG
(
FATAL
)
<<
"Not implemeted"
;
}
}
...
@@ -1438,20 +1438,20 @@ public:
...
@@ -1438,20 +1438,20 @@ public:
void
classificationError
(
Matrix
&
output
,
IVector
&
label
,
size_t
topkSize
=
1
);
void
classificationError
(
Matrix
&
output
,
IVector
&
label
,
size_t
topkSize
=
1
);
void
upsampleForward
(
Matrix
&
input
,
void
upsampleForward
(
Matrix
&
input
,
Matrix
&
mask
,
Matrix
&
mask
,
size_t
imgSizeH
,
size_t
imgSizeH
,
size_t
imgSizeW
,
size_t
imgSizeW
,
size_t
channels
,
size_t
channels
,
size_t
outputH
,
size_t
outputH
,
size_t
outputW
);
size_t
outputW
);
void
upsampleBackward
(
Matrix
&
outputGrad
,
void
upsampleBackward
(
Matrix
&
outputGrad
,
Matrix
&
mask
,
Matrix
&
mask
,
size_t
imgSizeH
,
size_t
imgSizeH
,
size_t
imgSizeW
,
size_t
imgSizeW
,
size_t
channels
,
size_t
channels
,
size_t
outputH
,
size_t
outputH
,
size_t
outputW
);
size_t
outputW
);
void
maxPoolForward
(
Matrix
&
inputMat
,
void
maxPoolForward
(
Matrix
&
inputMat
,
size_t
imgSizeH
,
size_t
imgSizeH
,
...
@@ -1726,20 +1726,20 @@ public:
...
@@ -1726,20 +1726,20 @@ public:
MatrixPtr
clone
(
size_t
height
,
size_t
width
,
bool
useGpu
=
false
);
MatrixPtr
clone
(
size_t
height
,
size_t
width
,
bool
useGpu
=
false
);
void
upsampleForward
(
Matrix
&
input
,
void
upsampleForward
(
Matrix
&
input
,
Matrix
&
mask
,
Matrix
&
mask
,
size_t
imgSizeH
,
size_t
imgSizeH
,
size_t
imgSizeW
,
size_t
imgSizeW
,
size_t
channels
,
size_t
channels
,
size_t
outputH
,
size_t
outputH
,
size_t
outputW
);
size_t
outputW
);
void
upsampleBackward
(
Matrix
&
outputGrad
,
void
upsampleBackward
(
Matrix
&
outputGrad
,
Matrix
&
mask
,
Matrix
&
mask
,
size_t
imgSizeH
,
size_t
imgSizeH
,
size_t
imgSizeW
,
size_t
imgSizeW
,
size_t
channels
,
size_t
channels
,
size_t
outputH
,
size_t
outputH
,
size_t
outputW
);
size_t
outputW
);
void
maxPoolForward
(
Matrix
&
inputMat
,
void
maxPoolForward
(
Matrix
&
inputMat
,
size_t
imgSizeH
,
size_t
imgSizeH
,
...
...
python/paddle/trainer/config_parser.py
浏览文件 @
6da00da7
...
@@ -978,12 +978,14 @@ class Pad(Cfg):
...
@@ -978,12 +978,14 @@ class Pad(Cfg):
def
__init__
(
self
,
channels
,
pad_c
,
pad_h
,
pad_w
):
def
__init__
(
self
,
channels
,
pad_c
,
pad_h
,
pad_w
):
self
.
add_keys
(
locals
())
self
.
add_keys
(
locals
())
@
config_class
@
config_class
class
Upsample
(
Cfg
):
class
Upsample
(
Cfg
):
def
__init__
(
self
,
scale
,
scale_y
,
pad_out_x
,
pad_out_y
,
upsample_size
,
def
__init__
(
self
,
scale
,
scale_y
,
pad_out_x
,
pad_out_y
,
upsample_size
,
upsample_size_y
):
upsample_size_y
):
self
.
add_keys
(
locals
())
self
.
add_keys
(
locals
())
@
config_class
@
config_class
class
Norm
(
Cfg
):
class
Norm
(
Cfg
):
def
__init__
(
self
,
def
__init__
(
self
,
...
@@ -2393,6 +2395,7 @@ class SpatialPyramidPoolLayer(LayerBase):
...
@@ -2393,6 +2395,7 @@ class SpatialPyramidPoolLayer(LayerBase):
output_x
=
(
pow
(
4
,
spp_conf
.
pyramid_height
)
-
1
)
/
(
4
-
1
)
output_x
=
(
pow
(
4
,
spp_conf
.
pyramid_height
)
-
1
)
/
(
4
-
1
)
self
.
set_cnn_layer
(
name
,
1
,
output_x
,
spp_conf
.
image_conf
.
channels
)
self
.
set_cnn_layer
(
name
,
1
,
output_x
,
spp_conf
.
image_conf
.
channels
)
@
config_layer
(
'upsample'
)
@
config_layer
(
'upsample'
)
class
UpsampleLayer
(
LayerBase
):
class
UpsampleLayer
(
LayerBase
):
def
__init__
(
self
,
name
,
inputs
,
**
xargs
):
def
__init__
(
self
,
name
,
inputs
,
**
xargs
):
...
@@ -2407,9 +2410,10 @@ class UpsampleLayer(LayerBase):
...
@@ -2407,9 +2410,10 @@ class UpsampleLayer(LayerBase):
input_layer
.
height
)
input_layer
.
height
)
upsample
=
self
.
inputs
[
0
].
upsample
upsample
=
self
.
inputs
[
0
].
upsample
output_x
=
0
output_x
=
0
output_y
=
0
output_y
=
0
output_size
=
0
output_size
=
0
if
upsample
.
scale
:
if
upsample
.
scale
:
self
.
config
.
inputs
[
0
].
upsample_conf
.
scale
=
upsample
.
scale
self
.
config
.
inputs
[
0
].
upsample_conf
.
scale
=
upsample
.
scale
self
.
config
.
inputs
[
0
].
upsample_conf
.
scale_y
=
upsample
.
scale_y
self
.
config
.
inputs
[
0
].
upsample_conf
.
scale_y
=
upsample
.
scale_y
...
@@ -2427,11 +2431,11 @@ class UpsampleLayer(LayerBase):
...
@@ -2427,11 +2431,11 @@ class UpsampleLayer(LayerBase):
output_size
=
image_conf
.
channels
*
output_x
*
output_y
output_size
=
image_conf
.
channels
*
output_x
*
output_y
self
.
set_layer_height_width
(
output_y
,
output_x
)
self
.
set_layer_height_width
(
output_y
,
output_x
)
self
.
set_layer_depth
(
input_layer
.
depth
)
self
.
set_layer_depth
(
input_layer
.
depth
)
self
.
set_layer_size
(
output_size
)
self
.
set_layer_size
(
output_size
)
@
config_layer
(
'pad'
)
@
config_layer
(
'pad'
)
class
PadLayer
(
LayerBase
):
class
PadLayer
(
LayerBase
):
def
__init__
(
self
,
name
,
inputs
,
**
xargs
):
def
__init__
(
self
,
name
,
inputs
,
**
xargs
):
...
...
python/paddle/trainer_config_helpers/layers.py
浏览文件 @
6da00da7
...
@@ -2881,6 +2881,7 @@ def img_pool3d_layer(input,
...
@@ -2881,6 +2881,7 @@ def img_pool3d_layer(input,
num_filters
=
num_channels
,
num_filters
=
num_channels
,
size
=
l
.
config
.
size
)
size
=
l
.
config
.
size
)
@
wrap_name_default
(
"upsample"
)
@
wrap_name_default
(
"upsample"
)
@
layer_support
()
@
layer_support
()
def
upsample_layer
(
input
,
def
upsample_layer
(
input
,
...
@@ -2930,6 +2931,7 @@ def upsample_layer(input,
...
@@ -2930,6 +2931,7 @@ def upsample_layer(input,
'scale or upsample_size, there must be one to be designated'
'scale or upsample_size, there must be one to be designated'
assert
len
(
input
)
==
2
,
'layer input size must be 2'
assert
len
(
input
)
==
2
,
'layer input size must be 2'
assert
input
[
1
].
layer_type
==
LayerType
.
POOL_LAYER
,
\
assert
input
[
1
].
layer_type
==
LayerType
.
POOL_LAYER
,
\
'the second input should be the MaxPoolWithMaskLayer'
'the second input should be the MaxPoolWithMaskLayer'
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录