Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
2859532d
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2299
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看板
提交
2859532d
编写于
2月 03, 2017
作者:
Y
Yu Yang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Using override keyword in Layer
上级
54ba8eaa
变更
73
隐藏空白更改
内联
并排
Showing
73 changed file
with
369 addition
and
300 deletion
+369
-300
paddle/gserver/gradientmachines/RecurrentGradientMachine.cpp
paddle/gserver/gradientmachines/RecurrentGradientMachine.cpp
+4
-3
paddle/gserver/layers/AddtoLayer.h
paddle/gserver/layers/AddtoLayer.h
+4
-3
paddle/gserver/layers/AgentLayer.h
paddle/gserver/layers/AgentLayer.h
+14
-11
paddle/gserver/layers/AverageLayer.h
paddle/gserver/layers/AverageLayer.h
+4
-5
paddle/gserver/layers/BatchNormBaseLayer.h
paddle/gserver/layers/BatchNormBaseLayer.h
+2
-1
paddle/gserver/layers/BatchNormalizationLayer.h
paddle/gserver/layers/BatchNormalizationLayer.h
+5
-4
paddle/gserver/layers/BilinearInterpLayer.h
paddle/gserver/layers/BilinearInterpLayer.h
+4
-3
paddle/gserver/layers/BlockExpandLayer.h
paddle/gserver/layers/BlockExpandLayer.h
+4
-3
paddle/gserver/layers/CRFDecodingLayer.h
paddle/gserver/layers/CRFDecodingLayer.h
+4
-3
paddle/gserver/layers/CRFLayer.h
paddle/gserver/layers/CRFLayer.h
+4
-3
paddle/gserver/layers/CTCLayer.h
paddle/gserver/layers/CTCLayer.h
+4
-3
paddle/gserver/layers/ConcatenateLayer.cpp
paddle/gserver/layers/ConcatenateLayer.cpp
+8
-6
paddle/gserver/layers/ConvBaseLayer.h
paddle/gserver/layers/ConvBaseLayer.h
+2
-1
paddle/gserver/layers/ConvShiftLayer.cpp
paddle/gserver/layers/ConvShiftLayer.cpp
+4
-3
paddle/gserver/layers/ConvexCombinationLayer.cpp
paddle/gserver/layers/ConvexCombinationLayer.cpp
+4
-3
paddle/gserver/layers/CosSimLayer.h
paddle/gserver/layers/CosSimLayer.h
+4
-3
paddle/gserver/layers/CosSimVecMatLayer.cpp
paddle/gserver/layers/CosSimVecMatLayer.cpp
+4
-3
paddle/gserver/layers/CostLayer.cpp
paddle/gserver/layers/CostLayer.cpp
+4
-5
paddle/gserver/layers/CostLayer.h
paddle/gserver/layers/CostLayer.h
+49
-30
paddle/gserver/layers/CudnnBatchNormLayer.h
paddle/gserver/layers/CudnnBatchNormLayer.h
+4
-3
paddle/gserver/layers/CudnnConvLayer.h
paddle/gserver/layers/CudnnConvLayer.h
+4
-3
paddle/gserver/layers/CudnnPoolLayer.h
paddle/gserver/layers/CudnnPoolLayer.h
+4
-3
paddle/gserver/layers/DataLayer.h
paddle/gserver/layers/DataLayer.h
+4
-4
paddle/gserver/layers/DataNormLayer.h
paddle/gserver/layers/DataNormLayer.h
+4
-3
paddle/gserver/layers/EosIdCheckLayer.cpp
paddle/gserver/layers/EosIdCheckLayer.cpp
+4
-4
paddle/gserver/layers/ExpandConvBaseLayer.h
paddle/gserver/layers/ExpandConvBaseLayer.h
+2
-1
paddle/gserver/layers/ExpandConvLayer.h
paddle/gserver/layers/ExpandConvLayer.h
+4
-3
paddle/gserver/layers/ExpandConvTransLayer.h
paddle/gserver/layers/ExpandConvTransLayer.h
+4
-3
paddle/gserver/layers/ExpandLayer.h
paddle/gserver/layers/ExpandLayer.h
+4
-3
paddle/gserver/layers/FeatureMapExpandLayer.cpp
paddle/gserver/layers/FeatureMapExpandLayer.cpp
+4
-3
paddle/gserver/layers/FullyConnectedLayer.h
paddle/gserver/layers/FullyConnectedLayer.h
+5
-4
paddle/gserver/layers/GatedRecurrentLayer.h
paddle/gserver/layers/GatedRecurrentLayer.h
+7
-6
paddle/gserver/layers/GetOutputLayer.cpp
paddle/gserver/layers/GetOutputLayer.cpp
+4
-3
paddle/gserver/layers/GruStepLayer.cpp
paddle/gserver/layers/GruStepLayer.cpp
+4
-3
paddle/gserver/layers/HierarchicalSigmoidLayer.h
paddle/gserver/layers/HierarchicalSigmoidLayer.h
+4
-3
paddle/gserver/layers/InterpolationLayer.cpp
paddle/gserver/layers/InterpolationLayer.cpp
+4
-3
paddle/gserver/layers/LstmLayer.h
paddle/gserver/layers/LstmLayer.h
+7
-6
paddle/gserver/layers/LstmStepLayer.cpp
paddle/gserver/layers/LstmStepLayer.cpp
+4
-3
paddle/gserver/layers/MDLstmLayer.cpp
paddle/gserver/layers/MDLstmLayer.cpp
+4
-3
paddle/gserver/layers/MaxIdLayer.cpp
paddle/gserver/layers/MaxIdLayer.cpp
+4
-4
paddle/gserver/layers/MaxLayer.h
paddle/gserver/layers/MaxLayer.h
+4
-5
paddle/gserver/layers/MaxOutLayer.h
paddle/gserver/layers/MaxOutLayer.h
+4
-3
paddle/gserver/layers/MixedLayer.h
paddle/gserver/layers/MixedLayer.h
+8
-7
paddle/gserver/layers/MultiplexLayer.cpp
paddle/gserver/layers/MultiplexLayer.cpp
+4
-3
paddle/gserver/layers/NCELayer.cpp
paddle/gserver/layers/NCELayer.cpp
+5
-4
paddle/gserver/layers/NormLayer.h
paddle/gserver/layers/NormLayer.h
+6
-4
paddle/gserver/layers/NormProjectionLayer.h
paddle/gserver/layers/NormProjectionLayer.h
+4
-3
paddle/gserver/layers/OuterProdLayer.cpp
paddle/gserver/layers/OuterProdLayer.cpp
+4
-3
paddle/gserver/layers/PadLayer.h
paddle/gserver/layers/PadLayer.h
+4
-3
paddle/gserver/layers/ParameterReluLayer.h
paddle/gserver/layers/ParameterReluLayer.h
+4
-3
paddle/gserver/layers/PoolLayer.h
paddle/gserver/layers/PoolLayer.h
+2
-1
paddle/gserver/layers/PoolProjectionLayer.h
paddle/gserver/layers/PoolProjectionLayer.h
+2
-2
paddle/gserver/layers/PowerLayer.cpp
paddle/gserver/layers/PowerLayer.cpp
+4
-3
paddle/gserver/layers/PrintLayer.cpp
paddle/gserver/layers/PrintLayer.cpp
+2
-2
paddle/gserver/layers/PriorBox.cpp
paddle/gserver/layers/PriorBox.cpp
+4
-3
paddle/gserver/layers/RecurrentLayer.cpp
paddle/gserver/layers/RecurrentLayer.cpp
+7
-6
paddle/gserver/layers/RecurrentLayerGroup.cpp
paddle/gserver/layers/RecurrentLayerGroup.cpp
+5
-4
paddle/gserver/layers/ResizeLayer.cpp
paddle/gserver/layers/ResizeLayer.cpp
+5
-4
paddle/gserver/layers/SamplingIdLayer.cpp
paddle/gserver/layers/SamplingIdLayer.cpp
+4
-4
paddle/gserver/layers/ScalingLayer.cpp
paddle/gserver/layers/ScalingLayer.cpp
+4
-3
paddle/gserver/layers/SelectiveFullyConnectedLayer.h
paddle/gserver/layers/SelectiveFullyConnectedLayer.h
+5
-4
paddle/gserver/layers/SequenceConcatLayer.cpp
paddle/gserver/layers/SequenceConcatLayer.cpp
+4
-3
paddle/gserver/layers/SequenceLastInstanceLayer.cpp
paddle/gserver/layers/SequenceLastInstanceLayer.cpp
+4
-5
paddle/gserver/layers/SequencePoolLayer.h
paddle/gserver/layers/SequencePoolLayer.h
+4
-5
paddle/gserver/layers/SequenceReshapeLayer.cpp
paddle/gserver/layers/SequenceReshapeLayer.cpp
+4
-5
paddle/gserver/layers/SlopeInterceptLayer.cpp
paddle/gserver/layers/SlopeInterceptLayer.cpp
+4
-5
paddle/gserver/layers/SpatialPyramidPoolLayer.h
paddle/gserver/layers/SpatialPyramidPoolLayer.h
+4
-5
paddle/gserver/layers/SubSequenceLayer.cpp
paddle/gserver/layers/SubSequenceLayer.cpp
+4
-5
paddle/gserver/layers/SumToOneNormLayer.cpp
paddle/gserver/layers/SumToOneNormLayer.cpp
+4
-5
paddle/gserver/layers/TensorLayer.h
paddle/gserver/layers/TensorLayer.h
+4
-5
paddle/gserver/layers/TransLayer.h
paddle/gserver/layers/TransLayer.h
+4
-3
paddle/gserver/layers/ValidationLayer.h
paddle/gserver/layers/ValidationLayer.h
+13
-10
paddle/gserver/layers/WarpCTCLayer.h
paddle/gserver/layers/WarpCTCLayer.h
+4
-3
未找到文件。
paddle/gserver/gradientmachines/RecurrentGradientMachine.cpp
浏览文件 @
2859532d
...
@@ -155,7 +155,8 @@ protected:
...
@@ -155,7 +155,8 @@ protected:
public:
public:
explicit
BootBiasLayer
(
const
LayerConfig
&
config
)
:
Layer
(
config
)
{}
explicit
BootBiasLayer
(
const
LayerConfig
&
config
)
:
Layer
(
config
)
{}
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
{
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
{
if
(
!
Layer
::
init
(
layerMap
,
parameterMap
))
return
false
;
if
(
!
Layer
::
init
(
layerMap
,
parameterMap
))
return
false
;
if
(
biasParameter_
)
{
if
(
biasParameter_
)
{
...
@@ -174,7 +175,7 @@ public:
...
@@ -174,7 +175,7 @@ public:
}
}
}
}
v
irtual
void
forward
(
PassType
passType
)
{
v
oid
forward
(
PassType
passType
)
override
{
if
(
biases_
)
{
if
(
biases_
)
{
MatrixPtr
outV
=
getOutputValue
();
MatrixPtr
outV
=
getOutputValue
();
outV
->
addBias
(
*
(
biases_
->
getW
()),
1
);
outV
->
addBias
(
*
(
biases_
->
getW
()),
1
);
...
@@ -182,7 +183,7 @@ public:
...
@@ -182,7 +183,7 @@ public:
}
}
}
}
v
irtual
void
backward
(
const
UpdateCallback
&
callback
)
{
v
oid
backward
(
const
UpdateCallback
&
callback
)
override
{
if
(
biases_
)
{
if
(
biases_
)
{
backwardActivation
();
backwardActivation
();
biases_
->
getWGrad
()
->
collectBias
(
*
getOutputGrad
(),
1
);
biases_
->
getWGrad
()
->
collectBias
(
*
getOutputGrad
(),
1
);
...
...
paddle/gserver/layers/AddtoLayer.h
浏览文件 @
2859532d
...
@@ -44,19 +44,20 @@ public:
...
@@ -44,19 +44,20 @@ public:
/**
/**
* Intialization of AddtoLayer.
* Intialization of AddtoLayer.
*/
*/
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
/**
/**
* Forward propagation.
* Forward propagation.
* @note There is no weight matrix for each input,
* @note There is no weight matrix for each input,
* because it just a simple add operation.
* because it just a simple add operation.
*/
*/
void
forward
(
PassType
passType
);
void
forward
(
PassType
passType
)
override
;
/**
/**
* Backward propagation.
* Backward propagation.
*/
*/
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
);
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
override
;
};
};
}
// namespace paddle
}
// namespace paddle
paddle/gserver/layers/AgentLayer.h
浏览文件 @
2859532d
...
@@ -35,7 +35,8 @@ public:
...
@@ -35,7 +35,8 @@ public:
~
AgentLayer
()
{}
~
AgentLayer
()
{}
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
// if *numSamples* set,
// if *numSamples* set,
// real layer output will only use first *numSamples* rows
// real layer output will only use first *numSamples* rows
...
@@ -44,8 +45,8 @@ public:
...
@@ -44,8 +45,8 @@ public:
numSamples_
=
numSamples
;
numSamples_
=
numSamples
;
}
}
void
forward
(
PassType
passType
);
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
{}
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
override
{}
};
};
/**
/**
...
@@ -56,8 +57,8 @@ public:
...
@@ -56,8 +57,8 @@ public:
explicit
SequenceAgentLayer
(
const
LayerConfig
&
config
)
:
AgentLayer
(
config
)
{}
explicit
SequenceAgentLayer
(
const
LayerConfig
&
config
)
:
AgentLayer
(
config
)
{}
~
SequenceAgentLayer
()
{}
~
SequenceAgentLayer
()
{}
void
forward
(
PassType
passType
);
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
{}
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
override
{}
};
};
/**
/**
...
@@ -78,7 +79,8 @@ public:
...
@@ -78,7 +79,8 @@ public:
virtual
~
GatherAgentLayer
()
{}
virtual
~
GatherAgentLayer
()
{}
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
// call before addRealLayer
// call before addRealLayer
void
copyIdAndSequenceInfo
(
const
Argument
&
input
,
void
copyIdAndSequenceInfo
(
const
Argument
&
input
,
...
@@ -88,8 +90,8 @@ public:
...
@@ -88,8 +90,8 @@ public:
// add one real layer, can call many times
// add one real layer, can call many times
void
addRealLayer
(
LayerPtr
layer
)
{
realLayers_
.
push_back
(
layer
);
}
void
addRealLayer
(
LayerPtr
layer
)
{
realLayers_
.
push_back
(
layer
);
}
void
forward
(
PassType
passType
);
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
);
void
backward
(
const
UpdateCallback
&
callback
)
override
;
};
};
/**
/**
...
@@ -133,7 +135,8 @@ public:
...
@@ -133,7 +135,8 @@ public:
virtual
~
ScatterAgentLayer
()
{}
virtual
~
ScatterAgentLayer
()
{}
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
/**
/**
* @brief set real layer in generation
* @brief set real layer in generation
...
@@ -182,8 +185,8 @@ public:
...
@@ -182,8 +185,8 @@ public:
numSequences_
=
numSequences
;
numSequences_
=
numSequences
;
}
}
void
forward
(
PassType
passType
);
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
);
void
backward
(
const
UpdateCallback
&
callback
)
override
;
};
};
/**
/**
...
...
paddle/gserver/layers/AverageLayer.h
浏览文件 @
2859532d
...
@@ -38,12 +38,11 @@ public:
...
@@ -38,12 +38,11 @@ public:
explicit
AverageLayer
(
const
LayerConfig
&
config
)
explicit
AverageLayer
(
const
LayerConfig
&
config
)
:
SequencePoolLayer
(
config
)
{}
:
SequencePoolLayer
(
config
)
{}
~
AverageLayer
()
{}
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
override
;
void
forward
(
PassType
passType
);
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
);
protected:
protected:
MatrixPtr
outMtx_
;
MatrixPtr
outMtx_
;
...
...
paddle/gserver/layers/BatchNormBaseLayer.h
浏览文件 @
2859532d
...
@@ -52,7 +52,8 @@ public:
...
@@ -52,7 +52,8 @@ public:
*/
*/
static
Layer
*
create
(
const
LayerConfig
&
config
);
static
Layer
*
create
(
const
LayerConfig
&
config
);
virtual
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
/**
/**
* @brief Calculate feature map size. Some input uses frameHeight and
* @brief Calculate feature map size. Some input uses frameHeight and
...
...
paddle/gserver/layers/BatchNormalizationLayer.h
浏览文件 @
2859532d
...
@@ -33,9 +33,10 @@ public:
...
@@ -33,9 +33,10 @@ public:
~
BatchNormalizationLayer
()
{}
~
BatchNormalizationLayer
()
{}
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
bool
init
(
const
LayerMap
&
layerMap
,
void
forward
(
PassType
passType
);
const
ParameterMap
&
parameterMap
)
override
;
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
);
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
override
;
protected:
protected:
/// Epsilon value used in the batch normalization formula.
/// Epsilon value used in the batch normalization formula.
...
@@ -58,7 +59,7 @@ protected:
...
@@ -58,7 +59,7 @@ protected:
/// to batch, channels* imagePixels.
/// to batch, channels* imagePixels.
void
shrinkMat
(
const
MatrixPtr
&
in
,
MatrixPtr
&
out
);
void
shrinkMat
(
const
MatrixPtr
&
in
,
MatrixPtr
&
out
);
void
onPassEnd
()
{
firstTest_
=
true
;
}
void
onPassEnd
()
override
{
firstTest_
=
true
;
}
MatrixPtr
tmpMat_
,
tmpGrad_
;
MatrixPtr
tmpMat_
,
tmpGrad_
;
MatrixPtr
expandedIn_
,
expandedOut_
;
MatrixPtr
expandedIn_
,
expandedOut_
;
...
...
paddle/gserver/layers/BilinearInterpLayer.h
浏览文件 @
2859532d
...
@@ -38,9 +38,10 @@ public:
...
@@ -38,9 +38,10 @@ public:
virtual
~
BilinearInterpLayer
()
{}
virtual
~
BilinearInterpLayer
()
{}
size_t
getSize
();
size_t
getSize
();
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
bool
init
(
const
LayerMap
&
layerMap
,
void
forward
(
PassType
passType
);
const
ParameterMap
&
parameterMap
)
override
;
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
);
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
override
;
};
};
}
// namespace paddle
}
// namespace paddle
paddle/gserver/layers/BlockExpandLayer.h
浏览文件 @
2859532d
...
@@ -58,10 +58,11 @@ public:
...
@@ -58,10 +58,11 @@ public:
~
BlockExpandLayer
()
{}
~
BlockExpandLayer
()
{}
virtual
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
v
irtual
void
forward
(
PassType
passType
)
;
v
oid
forward
(
PassType
passType
)
override
;
v
irtual
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
;
v
oid
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
override
;
};
};
}
// namespace paddle
}
// namespace paddle
paddle/gserver/layers/CRFDecodingLayer.h
浏览文件 @
2859532d
...
@@ -32,9 +32,10 @@ namespace paddle {
...
@@ -32,9 +32,10 @@ namespace paddle {
class
CRFDecodingLayer
:
public
CRFLayer
{
class
CRFDecodingLayer
:
public
CRFLayer
{
public:
public:
explicit
CRFDecodingLayer
(
const
LayerConfig
&
config
)
:
CRFLayer
(
config
)
{}
explicit
CRFDecodingLayer
(
const
LayerConfig
&
config
)
:
CRFLayer
(
config
)
{}
virtual
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
bool
init
(
const
LayerMap
&
layerMap
,
virtual
void
forward
(
PassType
passType
);
const
ParameterMap
&
parameterMap
)
override
;
virtual
void
backward
(
const
UpdateCallback
&
callback
);
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
)
override
;
protected:
protected:
std
::
unique_ptr
<
LinearChainCRF
>
crf_
;
std
::
unique_ptr
<
LinearChainCRF
>
crf_
;
...
...
paddle/gserver/layers/CRFLayer.h
浏览文件 @
2859532d
...
@@ -29,9 +29,10 @@ namespace paddle {
...
@@ -29,9 +29,10 @@ namespace paddle {
class
CRFLayer
:
public
Layer
{
class
CRFLayer
:
public
Layer
{
public:
public:
explicit
CRFLayer
(
const
LayerConfig
&
config
)
:
Layer
(
config
)
{}
explicit
CRFLayer
(
const
LayerConfig
&
config
)
:
Layer
(
config
)
{}
virtual
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
bool
init
(
const
LayerMap
&
layerMap
,
virtual
void
forward
(
PassType
passType
);
const
ParameterMap
&
parameterMap
)
override
;
virtual
void
backward
(
const
UpdateCallback
&
callback
);
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
)
override
;
protected:
protected:
size_t
numClasses_
;
size_t
numClasses_
;
...
...
paddle/gserver/layers/CTCLayer.h
浏览文件 @
2859532d
...
@@ -22,10 +22,11 @@ namespace paddle {
...
@@ -22,10 +22,11 @@ namespace paddle {
class
CTCLayer
:
public
Layer
{
class
CTCLayer
:
public
Layer
{
public:
public:
explicit
CTCLayer
(
const
LayerConfig
&
config
)
:
Layer
(
config
)
{}
explicit
CTCLayer
(
const
LayerConfig
&
config
)
:
Layer
(
config
)
{}
virtual
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
bool
init
(
const
LayerMap
&
layerMap
,
virtual
void
forward
(
PassType
passType
);
const
ParameterMap
&
parameterMap
)
override
;
void
forward
(
PassType
passType
)
override
;
void
forwardImp
(
const
Argument
&
softmaxSeqs
,
const
Argument
&
labelSeqs
);
void
forwardImp
(
const
Argument
&
softmaxSeqs
,
const
Argument
&
labelSeqs
);
v
irtual
void
backward
(
const
UpdateCallback
&
callback
)
;
v
oid
backward
(
const
UpdateCallback
&
callback
)
override
;
void
backwardImp
(
const
UpdateCallback
&
callback
,
void
backwardImp
(
const
UpdateCallback
&
callback
,
const
Argument
&
softmaxSeqs
,
const
Argument
&
softmaxSeqs
,
const
Argument
&
labelSeqs
);
const
Argument
&
labelSeqs
);
...
...
paddle/gserver/layers/ConcatenateLayer.cpp
浏览文件 @
2859532d
...
@@ -28,10 +28,11 @@ public:
...
@@ -28,10 +28,11 @@ public:
~
ConcatenateLayer
()
{}
~
ConcatenateLayer
()
{}
virtual
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
v
irtual
void
forward
(
PassType
passType
)
;
v
oid
forward
(
PassType
passType
)
override
;
v
irtual
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
;
v
oid
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
override
;
};
};
REGISTER_LAYER
(
concat
,
ConcatenateLayer
);
REGISTER_LAYER
(
concat
,
ConcatenateLayer
);
...
@@ -101,10 +102,11 @@ public:
...
@@ -101,10 +102,11 @@ public:
~
ConcatenateLayer2
()
{}
~
ConcatenateLayer2
()
{}
virtual
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
v
irtual
void
forward
(
PassType
passType
)
;
v
oid
forward
(
PassType
passType
)
override
;
v
irtual
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
;
v
oid
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
override
;
protected:
protected:
std
::
vector
<
std
::
unique_ptr
<
Projection
>>
projections_
;
std
::
vector
<
std
::
unique_ptr
<
Projection
>>
projections_
;
...
...
paddle/gserver/layers/ConvBaseLayer.h
浏览文件 @
2859532d
...
@@ -80,7 +80,8 @@ protected:
...
@@ -80,7 +80,8 @@ protected:
public:
public:
explicit
ConvBaseLayer
(
const
LayerConfig
&
config
)
:
Layer
(
config
)
{}
explicit
ConvBaseLayer
(
const
LayerConfig
&
config
)
:
Layer
(
config
)
{}
virtual
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
/**
/**
* imgSizeH_ and imgSizeW_ will be set according to the previous input layers
* imgSizeH_ and imgSizeW_ will be set according to the previous input layers
...
...
paddle/gserver/layers/ConvShiftLayer.cpp
浏览文件 @
2859532d
...
@@ -47,10 +47,11 @@ public:
...
@@ -47,10 +47,11 @@ public:
~
ConvShiftLayer
()
{}
~
ConvShiftLayer
()
{}
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
void
forward
(
PassType
passType
);
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
);
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
override
;
};
};
REGISTER_LAYER
(
conv_shift
,
ConvShiftLayer
);
REGISTER_LAYER
(
conv_shift
,
ConvShiftLayer
);
...
...
paddle/gserver/layers/ConvexCombinationLayer.cpp
浏览文件 @
2859532d
...
@@ -49,10 +49,11 @@ public:
...
@@ -49,10 +49,11 @@ public:
~
ConvexCombinationLayer
()
{}
~
ConvexCombinationLayer
()
{}
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
void
forward
(
PassType
passType
);
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
);
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
override
;
};
};
REGISTER_LAYER
(
convex_comb
,
ConvexCombinationLayer
);
REGISTER_LAYER
(
convex_comb
,
ConvexCombinationLayer
);
...
...
paddle/gserver/layers/CosSimLayer.h
浏览文件 @
2859532d
...
@@ -38,10 +38,11 @@ public:
...
@@ -38,10 +38,11 @@ public:
~
CosSimLayer
()
{}
~
CosSimLayer
()
{}
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
void
forward
(
PassType
passType
);
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
);
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
override
;
};
};
}
// namespace paddle
}
// namespace paddle
paddle/gserver/layers/CosSimVecMatLayer.cpp
浏览文件 @
2859532d
...
@@ -46,10 +46,11 @@ public:
...
@@ -46,10 +46,11 @@ public:
~
CosSimVecMatLayer
()
{}
~
CosSimVecMatLayer
()
{}
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
void
forward
(
PassType
passType
);
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
);
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
override
;
};
};
REGISTER_LAYER
(
cos_vm
,
CosSimVecMatLayer
);
REGISTER_LAYER
(
cos_vm
,
CosSimVecMatLayer
);
...
...
paddle/gserver/layers/CostLayer.cpp
浏览文件 @
2859532d
...
@@ -367,8 +367,6 @@ void LambdaCost::backward(const UpdateCallback& callback) {
...
@@ -367,8 +367,6 @@ void LambdaCost::backward(const UpdateCallback& callback) {
getInputGrad
(
0
)
->
add
(
*
marginGrad_
);
getInputGrad
(
0
)
->
add
(
*
marginGrad_
);
}
}
void
LambdaCost
::
onPassEnd
()
{}
void
LambdaCost
::
calcGrad
(
const
real
*
outputScore
,
void
LambdaCost
::
calcGrad
(
const
real
*
outputScore
,
const
real
*
score
,
const
real
*
score
,
real
*
gradData
,
real
*
gradData
,
...
@@ -611,14 +609,15 @@ class SumCostLayer : public Layer {
...
@@ -611,14 +609,15 @@ class SumCostLayer : public Layer {
public:
public:
explicit
SumCostLayer
(
const
LayerConfig
&
config
)
:
Layer
(
config
)
{}
explicit
SumCostLayer
(
const
LayerConfig
&
config
)
:
Layer
(
config
)
{}
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
{
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
{
bool
ret
=
Layer
::
init
(
layerMap
,
parameterMap
);
bool
ret
=
Layer
::
init
(
layerMap
,
parameterMap
);
if
(
!
ret
)
return
ret
;
if
(
!
ret
)
return
ret
;
CHECK_EQ
(
inputLayers_
.
size
(),
1UL
);
CHECK_EQ
(
inputLayers_
.
size
(),
1UL
);
return
true
;
return
true
;
}
}
v
irtual
void
forward
(
PassType
passType
)
{
v
oid
forward
(
PassType
passType
)
override
{
Layer
::
forward
(
passType
);
Layer
::
forward
(
passType
);
const
MatrixPtr
&
input
=
getInputValue
(
0
);
const
MatrixPtr
&
input
=
getInputValue
(
0
);
...
@@ -629,7 +628,7 @@ public:
...
@@ -629,7 +628,7 @@ public:
output_
.
value
->
sumRows
(
*
input
,
/* scaleSum= */
1
,
/* scaleDest= */
0
);
output_
.
value
->
sumRows
(
*
input
,
/* scaleSum= */
1
,
/* scaleDest= */
0
);
}
}
v
irtual
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
{
v
oid
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
override
{
getInputGrad
(
0
)
->
add
((
real
)
1
);
getInputGrad
(
0
)
->
add
((
real
)
1
);
}
}
};
};
...
...
paddle/gserver/layers/CostLayer.h
浏览文件 @
2859532d
...
@@ -32,15 +32,16 @@ class CostLayer : public Layer {
...
@@ -32,15 +32,16 @@ class CostLayer : public Layer {
public:
public:
explicit
CostLayer
(
const
LayerConfig
&
config
)
:
Layer
(
config
)
{}
explicit
CostLayer
(
const
LayerConfig
&
config
)
:
Layer
(
config
)
{}
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
LayerPtr
getOutputLayer
()
{
return
inputLayers_
[
0
];
}
LayerPtr
getOutputLayer
()
{
return
inputLayers_
[
0
];
}
LayerPtr
getLabelLayer
()
{
return
inputLayers_
[
1
];
}
LayerPtr
getLabelLayer
()
{
return
inputLayers_
[
1
];
}
v
irtual
void
forward
(
PassType
passType
)
;
v
oid
forward
(
PassType
passType
)
override
;
v
irtual
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
;
v
oid
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
override
;
virtual
void
forwardImp
(
Matrix
&
outputValue
,
virtual
void
forwardImp
(
Matrix
&
outputValue
,
Argument
&
label
,
Argument
&
label
,
...
@@ -68,11 +69,14 @@ public:
...
@@ -68,11 +69,14 @@ public:
explicit
MultiClassCrossEntropy
(
const
LayerConfig
&
config
)
explicit
MultiClassCrossEntropy
(
const
LayerConfig
&
config
)
:
CostLayer
(
config
)
{}
:
CostLayer
(
config
)
{}
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
void
forwardImp
(
Matrix
&
output
,
Argument
&
label
,
Matrix
&
cost
);
void
forwardImp
(
Matrix
&
output
,
Argument
&
label
,
Matrix
&
cost
)
override
;
void
backwardImp
(
Matrix
&
outputValue
,
Argument
&
label
,
Matrix
&
outputGrad
);
void
backwardImp
(
Matrix
&
outputValue
,
Argument
&
label
,
Matrix
&
outputGrad
)
override
;
};
};
/**
/**
...
@@ -95,11 +99,14 @@ public:
...
@@ -95,11 +99,14 @@ public:
explicit
MultiClassCrossEntropyWithSelfNorm
(
const
LayerConfig
&
config
)
explicit
MultiClassCrossEntropyWithSelfNorm
(
const
LayerConfig
&
config
)
:
CostLayer
(
config
)
{}
:
CostLayer
(
config
)
{}
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
void
forwardImp
(
Matrix
&
output
,
Argument
&
label
,
Matrix
&
cost
);
void
forwardImp
(
Matrix
&
output
,
Argument
&
label
,
Matrix
&
cost
)
override
;
void
backwardImp
(
Matrix
&
outputValue
,
Argument
&
label
,
Matrix
&
outputGrad
);
void
backwardImp
(
Matrix
&
outputValue
,
Argument
&
label
,
Matrix
&
outputGrad
)
override
;
protected:
protected:
MatrixPtr
sftMaxSum_
;
MatrixPtr
sftMaxSum_
;
...
@@ -117,11 +124,14 @@ public:
...
@@ -117,11 +124,14 @@ public:
explicit
SoftBinaryClassCrossEntropy
(
const
LayerConfig
&
config
)
explicit
SoftBinaryClassCrossEntropy
(
const
LayerConfig
&
config
)
:
CostLayer
(
config
)
{}
:
CostLayer
(
config
)
{}
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
void
forwardImp
(
Matrix
&
output
,
Argument
&
label
,
Matrix
&
cost
);
void
forwardImp
(
Matrix
&
output
,
Argument
&
label
,
Matrix
&
cost
)
override
;
void
backwardImp
(
Matrix
&
outputValue
,
Argument
&
label
,
Matrix
&
outputGrad
);
void
backwardImp
(
Matrix
&
outputValue
,
Argument
&
label
,
Matrix
&
outputGrad
)
override
;
protected:
protected:
MatrixPtr
targetPerDim_
;
MatrixPtr
targetPerDim_
;
...
@@ -139,11 +149,14 @@ public:
...
@@ -139,11 +149,14 @@ public:
explicit
SumOfSquaresCostLayer
(
const
LayerConfig
&
config
)
explicit
SumOfSquaresCostLayer
(
const
LayerConfig
&
config
)
:
CostLayer
(
config
)
{}
:
CostLayer
(
config
)
{}
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
void
forwardImp
(
Matrix
&
output
,
Argument
&
label
,
Matrix
&
cost
);
void
forwardImp
(
Matrix
&
output
,
Argument
&
label
,
Matrix
&
cost
)
override
;
void
backwardImp
(
Matrix
&
outputValue
,
Argument
&
label
,
Matrix
&
outputGrad
);
void
backwardImp
(
Matrix
&
outputValue
,
Argument
&
label
,
Matrix
&
outputGrad
)
override
;
};
};
/**
/**
...
@@ -162,17 +175,18 @@ class RankingCost : public Layer {
...
@@ -162,17 +175,18 @@ class RankingCost : public Layer {
public:
public:
explicit
RankingCost
(
const
LayerConfig
&
config
)
:
Layer
(
config
)
{}
explicit
RankingCost
(
const
LayerConfig
&
config
)
:
Layer
(
config
)
{}
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
LayerPtr
getOutputLayer
(
size_t
i
)
{
return
inputLayers_
[
i
];
}
LayerPtr
getOutputLayer
(
size_t
i
)
{
return
inputLayers_
[
i
];
}
LayerPtr
getLabelLayer
()
{
return
inputLayers_
[
2
];
}
LayerPtr
getLabelLayer
()
{
return
inputLayers_
[
2
];
}
void
forward
(
PassType
passType
);
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
);
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
override
;
void
onPassEnd
();
void
onPassEnd
()
override
;
void
forwardImp
(
Matrix
&
output
,
Argument
&
label
,
Matrix
&
cost
)
{
void
forwardImp
(
Matrix
&
output
,
Argument
&
label
,
Matrix
&
cost
)
{
(
void
)
output
;
(
void
)
output
;
...
@@ -214,17 +228,16 @@ class LambdaCost : public Layer {
...
@@ -214,17 +228,16 @@ class LambdaCost : public Layer {
public:
public:
explicit
LambdaCost
(
const
LayerConfig
&
config
)
:
Layer
(
config
)
{}
explicit
LambdaCost
(
const
LayerConfig
&
config
)
:
Layer
(
config
)
{}
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
LayerPtr
getOutputLayer
()
{
return
inputLayers_
[
0
];
}
LayerPtr
getOutputLayer
()
{
return
inputLayers_
[
0
];
}
LayerPtr
getScoreLayer
()
{
return
inputLayers_
[
1
];
}
LayerPtr
getScoreLayer
()
{
return
inputLayers_
[
1
];
}
void
forward
(
PassType
passType
);
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
);
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
override
;
void
onPassEnd
();
real
calcNDCG
(
const
real
*
outputScore
,
const
real
*
score
,
int
size
);
real
calcNDCG
(
const
real
*
outputScore
,
const
real
*
score
,
int
size
);
void
calcGrad
(
const
real
*
outputScore
,
void
calcGrad
(
const
real
*
outputScore
,
...
@@ -256,11 +269,14 @@ public:
...
@@ -256,11 +269,14 @@ public:
explicit
MultiBinaryLabelCrossEntropy
(
const
LayerConfig
&
config
)
explicit
MultiBinaryLabelCrossEntropy
(
const
LayerConfig
&
config
)
:
CostLayer
(
config
)
{}
:
CostLayer
(
config
)
{}
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
void
forwardImp
(
Matrix
&
output
,
Argument
&
label
,
Matrix
&
cost
);
void
forwardImp
(
Matrix
&
output
,
Argument
&
label
,
Matrix
&
cost
)
override
;
void
backwardImp
(
Matrix
&
outputValue
,
Argument
&
label
,
Matrix
&
outputGrad
);
void
backwardImp
(
Matrix
&
outputValue
,
Argument
&
label
,
Matrix
&
outputGrad
)
override
;
};
};
/**
/**
...
@@ -282,13 +298,16 @@ class HuberTwoClass : public CostLayer {
...
@@ -282,13 +298,16 @@ class HuberTwoClass : public CostLayer {
public:
public:
explicit
HuberTwoClass
(
const
LayerConfig
&
config
)
:
CostLayer
(
config
)
{}
explicit
HuberTwoClass
(
const
LayerConfig
&
config
)
:
CostLayer
(
config
)
{}
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
void
forwardImp
(
Matrix
&
output
,
Argument
&
label
,
Matrix
&
cost
);
void
forwardImp
(
Matrix
&
output
,
Argument
&
label
,
Matrix
&
cost
)
override
;
void
forwardImpIn
(
Matrix
&
output
,
Argument
&
label
,
Matrix
&
cost
);
void
forwardImpIn
(
Matrix
&
output
,
Argument
&
label
,
Matrix
&
cost
);
void
backwardImp
(
Matrix
&
outputValue
,
Argument
&
label
,
Matrix
&
outputGrad
);
void
backwardImp
(
Matrix
&
outputValue
,
Argument
&
label
,
Matrix
&
outputGrad
)
override
;
void
backwardImpIn
(
Matrix
&
outputValue
,
Argument
&
label
,
Matrix
&
outputGrad
);
void
backwardImpIn
(
Matrix
&
outputValue
,
Argument
&
label
,
Matrix
&
outputGrad
);
};
};
...
...
paddle/gserver/layers/CudnnBatchNormLayer.h
浏览文件 @
2859532d
...
@@ -35,14 +35,15 @@ public:
...
@@ -35,14 +35,15 @@ public:
~
CudnnBatchNormLayer
();
~
CudnnBatchNormLayer
();
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
/**
/**
* reshape tensor of ioDesc_.
* reshape tensor of ioDesc_.
*/
*/
void
reshape
(
int
batchSize
);
void
reshape
(
int
batchSize
);
void
forward
(
PassType
passType
);
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
);
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
override
;
protected:
protected:
/**
/**
...
...
paddle/gserver/layers/CudnnConvLayer.h
浏览文件 @
2859532d
...
@@ -45,9 +45,10 @@ public:
...
@@ -45,9 +45,10 @@ public:
~
CudnnConvLayer
();
~
CudnnConvLayer
();
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
bool
init
(
const
LayerMap
&
layerMap
,
void
forward
(
PassType
passType
);
const
ParameterMap
&
parameterMap
)
override
;
void
backward
(
const
UpdateCallback
&
callback
);
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
)
override
;
void
addBiases
();
void
addBiases
();
void
bpropBiases
();
void
bpropBiases
();
};
};
...
...
paddle/gserver/layers/CudnnPoolLayer.h
浏览文件 @
2859532d
...
@@ -45,7 +45,8 @@ public:
...
@@ -45,7 +45,8 @@ public:
hl_pooling_mode_t
*
mode
=
nullptr
);
hl_pooling_mode_t
*
mode
=
nullptr
);
explicit
CudnnPoolLayer
(
const
LayerConfig
&
config
);
explicit
CudnnPoolLayer
(
const
LayerConfig
&
config
);
~
CudnnPoolLayer
();
~
CudnnPoolLayer
();
virtual
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
/**
/**
* Reshape input and output tensor descriptor.
* Reshape input and output tensor descriptor.
...
@@ -53,8 +54,8 @@ public:
...
@@ -53,8 +54,8 @@ public:
* So reshaping is needed.
* So reshaping is needed.
*/
*/
void
reshape
(
int
batchSize
);
void
reshape
(
int
batchSize
);
virtual
void
forward
(
PassType
passType
);
virtual
void
forward
(
PassType
passType
)
override
;
virtual
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
);
virtual
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
override
;
};
};
}
// namespace paddle
}
// namespace paddle
paddle/gserver/layers/DataLayer.h
浏览文件 @
2859532d
...
@@ -33,13 +33,13 @@ public:
...
@@ -33,13 +33,13 @@ public:
/**
/**
* Prefetch sparse matrix/ids only.
* Prefetch sparse matrix/ids only.
*/
*/
void
prefetch
()
{
output_
=
data_
;
}
void
prefetch
()
override
{
output_
=
data_
;
}
/**
/**
* Forward propagation. Copy data_ (value, in, grad, ids, cpuSequenceDims,
* Forward propagation. Copy data_ (value, in, grad, ids, cpuSequenceDims,
* sequenceStartPositions, subSequenceStartPositions, strs) to output_.
* sequenceStartPositions, subSequenceStartPositions, strs) to output_.
*/
*/
v
irtual
void
forward
(
PassType
passType
)
{
v
oid
forward
(
PassType
passType
)
override
{
Layer
::
forward
(
passType
);
Layer
::
forward
(
passType
);
copyDataToOutput
(
output_
);
copyDataToOutput
(
output_
);
if
(
FLAGS_show_layer_stat
)
{
if
(
FLAGS_show_layer_stat
)
{
...
@@ -50,9 +50,9 @@ public:
...
@@ -50,9 +50,9 @@ public:
/**
/**
* Data layer's backward propagation do nothing.
* Data layer's backward propagation do nothing.
*/
*/
v
irtual
void
backward
(
const
UpdateCallback
&
callback
)
{
(
void
)
callback
;
}
v
oid
backward
(
const
UpdateCallback
&
callback
)
override
{
(
void
)
callback
;
}
v
irtual
void
copyOutputToOtherDevice
()
{
v
oid
copyOutputToOtherDevice
()
override
{
for
(
size_t
i
=
0
;
i
!=
outputOtherDevice_
.
size
();
i
++
)
{
for
(
size_t
i
=
0
;
i
!=
outputOtherDevice_
.
size
();
i
++
)
{
copyDataToOutput
(
outputOtherDevice_
[
i
]);
copyDataToOutput
(
outputOtherDevice_
[
i
]);
}
}
...
...
paddle/gserver/layers/DataNormLayer.h
浏览文件 @
2859532d
...
@@ -44,10 +44,11 @@ public:
...
@@ -44,10 +44,11 @@ public:
~
DataNormLayer
()
{}
~
DataNormLayer
()
{}
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
void
forward
(
PassType
passType
);
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
);
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
override
;
protected:
protected:
int
mode_
;
int
mode_
;
...
...
paddle/gserver/layers/EosIdCheckLayer.cpp
浏览文件 @
2859532d
...
@@ -27,14 +27,14 @@ class EosIdCheckLayer : public Layer {
...
@@ -27,14 +27,14 @@ class EosIdCheckLayer : public Layer {
public:
public:
explicit
EosIdCheckLayer
(
const
LayerConfig
&
config
)
:
Layer
(
config
)
{}
explicit
EosIdCheckLayer
(
const
LayerConfig
&
config
)
:
Layer
(
config
)
{}
virtual
bool
init
(
const
LayerMap
&
layerMap
,
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
{
const
ParameterMap
&
parameterMap
)
override
{
bool
ret
=
Layer
::
init
(
layerMap
,
parameterMap
);
bool
ret
=
Layer
::
init
(
layerMap
,
parameterMap
);
CHECK_EQ
(
1UL
,
inputLayers_
.
size
());
CHECK_EQ
(
1UL
,
inputLayers_
.
size
());
return
ret
;
return
ret
;
}
}
v
irtual
void
forward
(
PassType
passType
)
{
v
oid
forward
(
PassType
passType
)
override
{
Layer
::
forward
(
passType
);
Layer
::
forward
(
passType
);
const
Argument
&
input
=
getInput
(
0
);
const
Argument
&
input
=
getInput
(
0
);
...
@@ -42,7 +42,7 @@ public:
...
@@ -42,7 +42,7 @@ public:
output_
.
ids
->
isEqualTo
(
*
input
.
ids
,
config_
.
eos_id
());
output_
.
ids
->
isEqualTo
(
*
input
.
ids
,
config_
.
eos_id
());
}
}
v
irtual
void
backward
(
const
UpdateCallback
&
callback
)
{}
v
oid
backward
(
const
UpdateCallback
&
callback
)
override
{}
};
};
REGISTER_LAYER
(
eos_id
,
EosIdCheckLayer
);
REGISTER_LAYER
(
eos_id
,
EosIdCheckLayer
);
...
...
paddle/gserver/layers/ExpandConvBaseLayer.h
浏览文件 @
2859532d
...
@@ -48,7 +48,8 @@ public:
...
@@ -48,7 +48,8 @@ public:
~
ExpandConvBaseLayer
()
{}
~
ExpandConvBaseLayer
()
{}
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
size_t
getOutputSize
();
size_t
getOutputSize
();
/**
/**
...
...
paddle/gserver/layers/ExpandConvLayer.h
浏览文件 @
2859532d
...
@@ -35,10 +35,11 @@ public:
...
@@ -35,10 +35,11 @@ public:
~
ExpandConvLayer
()
{}
~
ExpandConvLayer
()
{}
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
void
forward
(
PassType
passType
);
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
);
void
backward
(
const
UpdateCallback
&
callback
)
override
;
};
};
}
// namespace paddle
}
// namespace paddle
paddle/gserver/layers/ExpandConvTransLayer.h
浏览文件 @
2859532d
...
@@ -34,10 +34,11 @@ public:
...
@@ -34,10 +34,11 @@ public:
~
ExpandConvTransLayer
()
{}
~
ExpandConvTransLayer
()
{}
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
void
forward
(
PassType
passType
);
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
);
void
backward
(
const
UpdateCallback
&
callback
)
override
;
};
};
}
// namespace paddle
}
// namespace paddle
paddle/gserver/layers/ExpandLayer.h
浏览文件 @
2859532d
...
@@ -53,10 +53,11 @@ public:
...
@@ -53,10 +53,11 @@ public:
~
ExpandLayer
()
{}
~
ExpandLayer
()
{}
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
void
forward
(
PassType
passType
);
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
);
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
override
;
};
};
}
// namespace paddle
}
// namespace paddle
paddle/gserver/layers/FeatureMapExpandLayer.cpp
浏览文件 @
2859532d
...
@@ -46,10 +46,11 @@ public:
...
@@ -46,10 +46,11 @@ public:
~
FeatureMapExpandLayer
()
{}
~
FeatureMapExpandLayer
()
{}
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
void
forward
(
PassType
passType
);
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
);
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
override
;
};
};
REGISTER_LAYER
(
featmap_expand
,
FeatureMapExpandLayer
);
REGISTER_LAYER
(
featmap_expand
,
FeatureMapExpandLayer
);
...
...
paddle/gserver/layers/FullyConnectedLayer.h
浏览文件 @
2859532d
...
@@ -36,13 +36,14 @@ public:
...
@@ -36,13 +36,14 @@ public:
explicit
FullyConnectedLayer
(
const
LayerConfig
&
config
)
:
Layer
(
config
)
{}
explicit
FullyConnectedLayer
(
const
LayerConfig
&
config
)
:
Layer
(
config
)
{}
~
FullyConnectedLayer
()
{}
~
FullyConnectedLayer
()
{}
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
Weight
&
getWeight
(
int
idx
)
{
return
*
weights_
[
idx
];
}
Weight
&
getWeight
(
int
idx
)
{
return
*
weights_
[
idx
];
}
void
prefetch
();
void
prefetch
()
override
;
void
forward
(
PassType
passType
);
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
);
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
override
;
};
};
}
// namespace paddle
}
// namespace paddle
paddle/gserver/layers/GatedRecurrentLayer.h
浏览文件 @
2859532d
...
@@ -50,17 +50,18 @@ class GatedRecurrentLayer : public Layer, public GruCompute {
...
@@ -50,17 +50,18 @@ class GatedRecurrentLayer : public Layer, public GruCompute {
public:
public:
explicit
GatedRecurrentLayer
(
const
LayerConfig
&
config
)
:
Layer
(
config
)
{}
explicit
GatedRecurrentLayer
(
const
LayerConfig
&
config
)
:
Layer
(
config
)
{}
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
void
forward
(
PassType
passType
);
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
);
void
backward
(
const
UpdateCallback
&
callback
)
override
;
void
resetState
();
void
resetState
()
override
;
void
setState
(
LayerStatePtr
state
);
void
setState
(
LayerStatePtr
state
)
override
;
LayerStatePtr
getState
();
LayerStatePtr
getState
()
override
;
protected:
protected:
void
forwardSequence
(
int
batchSize
,
void
forwardSequence
(
int
batchSize
,
...
...
paddle/gserver/layers/GetOutputLayer.cpp
浏览文件 @
2859532d
...
@@ -22,17 +22,18 @@ public:
...
@@ -22,17 +22,18 @@ public:
~
GetOutputLayer
()
{}
~
GetOutputLayer
()
{}
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
{
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
{
if
(
!
Layer
::
init
(
layerMap
,
parameterMap
))
return
false
;
if
(
!
Layer
::
init
(
layerMap
,
parameterMap
))
return
false
;
CHECK_EQ
(
1U
,
inputLayers_
.
size
());
CHECK_EQ
(
1U
,
inputLayers_
.
size
());
CHECK_NE
(
inputArgument_
[
0
],
""
);
CHECK_NE
(
inputArgument_
[
0
],
""
);
return
true
;
return
true
;
}
}
void
forward
(
PassType
passType
)
{
void
forward
(
PassType
passType
)
override
{
output_
=
getPrev
(
0
)
->
getOutput
(
inputArgument_
[
0
]);
output_
=
getPrev
(
0
)
->
getOutput
(
inputArgument_
[
0
]);
}
}
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
{}
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
override
{}
};
};
REGISTER_LAYER
(
get_output
,
GetOutputLayer
);
REGISTER_LAYER
(
get_output
,
GetOutputLayer
);
...
...
paddle/gserver/layers/GruStepLayer.cpp
浏览文件 @
2859532d
...
@@ -55,10 +55,11 @@ public:
...
@@ -55,10 +55,11 @@ public:
~
GruStepLayer
()
{}
~
GruStepLayer
()
{}
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
void
forward
(
PassType
passType
);
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
);
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
override
;
};
};
REGISTER_LAYER
(
gru_step
,
GruStepLayer
);
REGISTER_LAYER
(
gru_step
,
GruStepLayer
);
...
...
paddle/gserver/layers/HierarchicalSigmoidLayer.h
浏览文件 @
2859532d
...
@@ -61,9 +61,10 @@ class HierarchicalSigmoidLayer : public Layer {
...
@@ -61,9 +61,10 @@ class HierarchicalSigmoidLayer : public Layer {
public:
public:
explicit
HierarchicalSigmoidLayer
(
const
LayerConfig
&
config
)
explicit
HierarchicalSigmoidLayer
(
const
LayerConfig
&
config
)
:
Layer
(
config
)
{}
:
Layer
(
config
)
{}
virtual
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
bool
init
(
const
LayerMap
&
layerMap
,
virtual
void
forward
(
PassType
passType
);
const
ParameterMap
&
parameterMap
)
override
;
virtual
void
backward
(
const
UpdateCallback
&
callback
);
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
)
override
;
protected:
protected:
/**
/**
...
...
paddle/gserver/layers/InterpolationLayer.cpp
浏览文件 @
2859532d
...
@@ -43,10 +43,11 @@ public:
...
@@ -43,10 +43,11 @@ public:
~
InterpolationLayer
()
{}
~
InterpolationLayer
()
{}
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
void
forward
(
PassType
passType
);
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
);
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
override
;
};
};
REGISTER_LAYER
(
interpolation
,
InterpolationLayer
);
REGISTER_LAYER
(
interpolation
,
InterpolationLayer
);
...
...
paddle/gserver/layers/LstmLayer.h
浏览文件 @
2859532d
...
@@ -74,17 +74,18 @@ class LstmLayer : public Layer, public LstmCompute {
...
@@ -74,17 +74,18 @@ class LstmLayer : public Layer, public LstmCompute {
public:
public:
explicit
LstmLayer
(
const
LayerConfig
&
config
)
:
Layer
(
config
)
{}
explicit
LstmLayer
(
const
LayerConfig
&
config
)
:
Layer
(
config
)
{}
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
void
forward
(
PassType
passType
);
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
);
void
backward
(
const
UpdateCallback
&
callback
)
override
;
void
resetState
();
void
resetState
()
override
;
void
setState
(
LayerStatePtr
state
);
void
setState
(
LayerStatePtr
state
)
override
;
LayerStatePtr
getState
();
LayerStatePtr
getState
()
override
;
protected:
protected:
/**
/**
...
...
paddle/gserver/layers/LstmStepLayer.cpp
浏览文件 @
2859532d
...
@@ -35,10 +35,11 @@ public:
...
@@ -35,10 +35,11 @@ public:
~
LstmStepLayer
()
{}
~
LstmStepLayer
()
{}
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
void
forward
(
PassType
passType
);
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
);
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
override
;
};
};
REGISTER_LAYER
(
lstm_step
,
LstmStepLayer
);
REGISTER_LAYER
(
lstm_step
,
LstmStepLayer
);
...
...
paddle/gserver/layers/MDLstmLayer.cpp
浏览文件 @
2859532d
...
@@ -181,11 +181,12 @@ class MDLstmLayer : public LstmLayer {
...
@@ -181,11 +181,12 @@ class MDLstmLayer : public LstmLayer {
public:
public:
explicit
MDLstmLayer
(
const
LayerConfig
&
config
)
:
LstmLayer
(
config
)
{}
explicit
MDLstmLayer
(
const
LayerConfig
&
config
)
:
LstmLayer
(
config
)
{}
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
void
forward
(
PassType
passType
);
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
);
void
backward
(
const
UpdateCallback
&
callback
)
override
;
protected:
protected:
void
forwardOneSequence
(
int
start
,
CoordIterator
&
coordIter
);
void
forwardOneSequence
(
int
start
,
CoordIterator
&
coordIter
);
...
...
paddle/gserver/layers/MaxIdLayer.cpp
浏览文件 @
2859532d
...
@@ -30,8 +30,8 @@ private:
...
@@ -30,8 +30,8 @@ private:
public:
public:
explicit
MaxIdLayer
(
const
LayerConfig
&
config
)
:
Layer
(
config
)
{}
explicit
MaxIdLayer
(
const
LayerConfig
&
config
)
:
Layer
(
config
)
{}
virtual
bool
init
(
const
LayerMap
&
layerMap
,
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
{
const
ParameterMap
&
parameterMap
)
override
{
bool
ret
=
Layer
::
init
(
layerMap
,
parameterMap
);
bool
ret
=
Layer
::
init
(
layerMap
,
parameterMap
);
CHECK_EQ
(
1UL
,
inputLayers_
.
size
());
CHECK_EQ
(
1UL
,
inputLayers_
.
size
());
...
@@ -40,7 +40,7 @@ public:
...
@@ -40,7 +40,7 @@ public:
return
ret
;
return
ret
;
}
}
v
irtual
void
forward
(
PassType
passType
)
{
v
oid
forward
(
PassType
passType
)
override
{
Layer
::
forward
(
passType
);
Layer
::
forward
(
passType
);
const
Argument
&
input
=
getInput
(
0
);
const
Argument
&
input
=
getInput
(
0
);
size_t
batchSize
=
input
.
getBatchSize
();
size_t
batchSize
=
input
.
getBatchSize
();
...
@@ -54,7 +54,7 @@ public:
...
@@ -54,7 +54,7 @@ public:
input
.
value
->
rowMax
(
*
output_
.
ids
,
*
output_
.
in
);
input
.
value
->
rowMax
(
*
output_
.
ids
,
*
output_
.
in
);
}
}
v
irtual
void
backward
(
const
UpdateCallback
&
callback
)
{}
v
oid
backward
(
const
UpdateCallback
&
callback
)
override
{}
};
};
REGISTER_LAYER
(
maxid
,
MaxIdLayer
);
REGISTER_LAYER
(
maxid
,
MaxIdLayer
);
...
...
paddle/gserver/layers/MaxLayer.h
浏览文件 @
2859532d
...
@@ -42,14 +42,13 @@ protected:
...
@@ -42,14 +42,13 @@ protected:
public:
public:
explicit
MaxLayer
(
const
LayerConfig
&
config
)
:
SequencePoolLayer
(
config
)
{}
explicit
MaxLayer
(
const
LayerConfig
&
config
)
:
SequencePoolLayer
(
config
)
{}
~
MaxLayer
()
{}
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
{
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
{
return
SequencePoolLayer
::
init
(
layerMap
,
parameterMap
);
return
SequencePoolLayer
::
init
(
layerMap
,
parameterMap
);
}
}
void
forward
(
PassType
passType
);
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
);
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
override
;
};
};
}
// namespace paddle
}
// namespace paddle
paddle/gserver/layers/MaxOutLayer.h
浏览文件 @
2859532d
...
@@ -45,10 +45,11 @@ public:
...
@@ -45,10 +45,11 @@ public:
explicit
MaxOutLayer
(
const
LayerConfig
&
config
)
:
Layer
(
config
)
{}
explicit
MaxOutLayer
(
const
LayerConfig
&
config
)
:
Layer
(
config
)
{}
virtual
~
MaxOutLayer
()
{}
virtual
~
MaxOutLayer
()
{}
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
void
forward
(
PassType
passType
);
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
);
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
override
;
};
};
}
// namespace paddle
}
// namespace paddle
paddle/gserver/layers/MixedLayer.h
浏览文件 @
2859532d
...
@@ -35,21 +35,22 @@ public:
...
@@ -35,21 +35,22 @@ public:
~
MixedLayer
()
{}
~
MixedLayer
()
{}
virtual
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
v
irtual
void
prefetch
()
;
v
oid
prefetch
()
override
;
v
irtual
void
forward
(
PassType
passType
)
;
v
oid
forward
(
PassType
passType
)
override
;
v
irtual
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
;
v
oid
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
override
;
v
irtual
void
resetState
()
;
v
oid
resetState
()
override
;
/**
/**
* setState() should be called after getState().
* setState() should be called after getState().
* Argument state consists of all projections states.
* Argument state consists of all projections states.
*/
*/
v
irtual
void
setState
(
LayerStatePtr
state
)
;
v
oid
setState
(
LayerStatePtr
state
)
override
;
/**
/**
* Return state which consists of all projections states.
* Return state which consists of all projections states.
*/
*/
virtual
LayerStatePtr
getState
()
;
LayerStatePtr
getState
()
override
;
protected:
protected:
std
::
vector
<
std
::
unique_ptr
<
Projection
>>
projections_
;
std
::
vector
<
std
::
unique_ptr
<
Projection
>>
projections_
;
...
...
paddle/gserver/layers/MultiplexLayer.cpp
浏览文件 @
2859532d
...
@@ -69,10 +69,11 @@ public:
...
@@ -69,10 +69,11 @@ public:
~
MultiplexLayer
()
{}
~
MultiplexLayer
()
{}
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
void
forward
(
PassType
passType
);
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
);
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
override
;
private:
private:
/**
/**
...
...
paddle/gserver/layers/NCELayer.cpp
浏览文件 @
2859532d
...
@@ -61,7 +61,8 @@ public:
...
@@ -61,7 +61,8 @@ public:
rand_
(
0
,
config
.
num_classes
()
-
1
),
rand_
(
0
,
config
.
num_classes
()
-
1
),
prepared_
(
false
)
{}
prepared_
(
false
)
{}
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
{
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
{
/* Initialize the basic parent class */
/* Initialize the basic parent class */
Layer
::
init
(
layerMap
,
parameterMap
);
Layer
::
init
(
layerMap
,
parameterMap
);
...
@@ -146,7 +147,7 @@ public:
...
@@ -146,7 +147,7 @@ public:
prepared_
=
true
;
prepared_
=
true
;
}
}
void
prefetch
()
{
void
prefetch
()
override
{
prepareSamples
();
prepareSamples
();
IVector
::
resizeOrCreate
(
labelIds_
,
samples_
.
size
(),
useGpu_
);
IVector
::
resizeOrCreate
(
labelIds_
,
samples_
.
size
(),
useGpu_
);
int
*
ids
=
labelIds_
->
getData
();
int
*
ids
=
labelIds_
->
getData
();
...
@@ -163,7 +164,7 @@ public:
...
@@ -163,7 +164,7 @@ public:
}
}
}
}
void
forward
(
PassType
passType
)
{
void
forward
(
PassType
passType
)
override
{
Layer
::
forward
(
passType
);
Layer
::
forward
(
passType
);
CHECK
(
!
useGpu_
)
<<
"GPU is not supported"
;
CHECK
(
!
useGpu_
)
<<
"GPU is not supported"
;
...
@@ -199,7 +200,7 @@ public:
...
@@ -199,7 +200,7 @@ public:
forwardCost
();
forwardCost
();
}
}
void
backward
(
const
UpdateCallback
&
callback
)
{
void
backward
(
const
UpdateCallback
&
callback
)
override
{
Matrix
::
resizeOrCreate
(
sampleOut_
.
grad
,
Matrix
::
resizeOrCreate
(
sampleOut_
.
grad
,
1
,
1
,
samples_
.
size
(),
samples_
.
size
(),
...
...
paddle/gserver/layers/NormLayer.h
浏览文件 @
2859532d
...
@@ -30,7 +30,8 @@ class NormLayer : public Layer {
...
@@ -30,7 +30,8 @@ class NormLayer : public Layer {
public:
public:
explicit
NormLayer
(
const
LayerConfig
&
config
)
:
Layer
(
config
)
{}
explicit
NormLayer
(
const
LayerConfig
&
config
)
:
Layer
(
config
)
{}
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
{
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
{
Layer
::
init
(
layerMap
,
parameterMap
);
Layer
::
init
(
layerMap
,
parameterMap
);
return
true
;
return
true
;
}
}
...
@@ -56,9 +57,10 @@ protected:
...
@@ -56,9 +57,10 @@ protected:
public:
public:
explicit
ResponseNormLayer
(
const
LayerConfig
&
config
)
:
NormLayer
(
config
)
{}
explicit
ResponseNormLayer
(
const
LayerConfig
&
config
)
:
NormLayer
(
config
)
{}
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
bool
init
(
const
LayerMap
&
layerMap
,
void
forward
(
PassType
passType
)
{
LOG
(
FATAL
)
<<
"Not implemented"
;
}
const
ParameterMap
&
parameterMap
)
override
;
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
{
void
forward
(
PassType
passType
)
override
{
LOG
(
FATAL
)
<<
"Not implemented"
;
}
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
override
{
LOG
(
FATAL
)
<<
"Not implemented"
;
LOG
(
FATAL
)
<<
"Not implemented"
;
}
}
};
};
...
...
paddle/gserver/layers/NormProjectionLayer.h
浏览文件 @
2859532d
...
@@ -36,9 +36,10 @@ public:
...
@@ -36,9 +36,10 @@ public:
size_t
getSize
();
size_t
getSize
();
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
bool
init
(
const
LayerMap
&
layerMap
,
void
forward
(
PassType
passType
);
const
ParameterMap
&
parameterMap
)
override
;
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
);
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
override
;
protected:
protected:
TensorShape
shape_
;
TensorShape
shape_
;
...
...
paddle/gserver/layers/OuterProdLayer.cpp
浏览文件 @
2859532d
...
@@ -38,10 +38,11 @@ public:
...
@@ -38,10 +38,11 @@ public:
~
OuterProdLayer
()
{}
~
OuterProdLayer
()
{}
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
void
forward
(
PassType
passType
);
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
);
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
override
;
};
};
REGISTER_LAYER
(
out_prod
,
OuterProdLayer
);
REGISTER_LAYER
(
out_prod
,
OuterProdLayer
);
...
...
paddle/gserver/layers/PadLayer.h
浏览文件 @
2859532d
...
@@ -29,9 +29,10 @@ public:
...
@@ -29,9 +29,10 @@ public:
~
PadLayer
()
{}
~
PadLayer
()
{}
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
bool
init
(
const
LayerMap
&
layerMap
,
void
forward
(
PassType
passType
);
const
ParameterMap
&
parameterMap
)
override
;
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
);
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
override
;
protected:
protected:
void
setOutDims
(
const
size_t
batchSize
);
void
setOutDims
(
const
size_t
batchSize
);
...
...
paddle/gserver/layers/ParameterReluLayer.h
浏览文件 @
2859532d
...
@@ -56,9 +56,10 @@ public:
...
@@ -56,9 +56,10 @@ public:
~
ParameterReluLayer
()
{}
~
ParameterReluLayer
()
{}
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
void
forward
(
PassType
passType
);
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
);
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
override
;
};
};
}
// namespace paddle
}
// namespace paddle
paddle/gserver/layers/PoolLayer.h
浏览文件 @
2859532d
...
@@ -46,7 +46,8 @@ public:
...
@@ -46,7 +46,8 @@ public:
*/
*/
static
Layer
*
create
(
const
LayerConfig
&
config
);
static
Layer
*
create
(
const
LayerConfig
&
config
);
virtual
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
};
};
}
// namespace paddle
}
// namespace paddle
paddle/gserver/layers/PoolProjectionLayer.h
浏览文件 @
2859532d
...
@@ -40,7 +40,7 @@ public:
...
@@ -40,7 +40,7 @@ public:
size_t
getSize
();
size_t
getSize
();
v
irtual
void
forward
(
PassType
passType
)
;
v
oid
forward
(
PassType
passType
)
override
;
v
irtual
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
;
v
oid
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
override
;
};
};
}
// namespace paddle
}
// namespace paddle
paddle/gserver/layers/PowerLayer.cpp
浏览文件 @
2859532d
...
@@ -40,10 +40,11 @@ public:
...
@@ -40,10 +40,11 @@ public:
~
PowerLayer
()
{}
~
PowerLayer
()
{}
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
void
forward
(
PassType
passType
);
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
);
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
override
;
};
};
REGISTER_LAYER
(
power
,
PowerLayer
);
REGISTER_LAYER
(
power
,
PowerLayer
);
...
...
paddle/gserver/layers/PrintLayer.cpp
浏览文件 @
2859532d
...
@@ -19,8 +19,8 @@ namespace paddle {
...
@@ -19,8 +19,8 @@ namespace paddle {
class
PrintLayer
:
public
Layer
{
class
PrintLayer
:
public
Layer
{
public:
public:
explicit
PrintLayer
(
const
LayerConfig
&
config
)
:
Layer
(
config
)
{}
explicit
PrintLayer
(
const
LayerConfig
&
config
)
:
Layer
(
config
)
{}
void
forward
(
PassType
passType
);
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
)
{}
void
backward
(
const
UpdateCallback
&
callback
)
override
{}
};
};
void
PrintLayer
::
forward
(
PassType
passType
)
{
void
PrintLayer
::
forward
(
PassType
passType
)
{
...
...
paddle/gserver/layers/PriorBox.cpp
浏览文件 @
2859532d
...
@@ -30,10 +30,11 @@ namespace paddle {
...
@@ -30,10 +30,11 @@ namespace paddle {
class
PriorBoxLayer
:
public
Layer
{
class
PriorBoxLayer
:
public
Layer
{
public:
public:
explicit
PriorBoxLayer
(
const
LayerConfig
&
config
)
:
Layer
(
config
)
{}
explicit
PriorBoxLayer
(
const
LayerConfig
&
config
)
:
Layer
(
config
)
{}
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
void
forward
(
PassType
passType
);
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
)
{}
void
backward
(
const
UpdateCallback
&
callback
)
override
{}
protected:
protected:
int
numPriors_
;
int
numPriors_
;
...
...
paddle/gserver/layers/RecurrentLayer.cpp
浏览文件 @
2859532d
...
@@ -45,17 +45,18 @@ class RecurrentLayer : public Layer {
...
@@ -45,17 +45,18 @@ class RecurrentLayer : public Layer {
public:
public:
explicit
RecurrentLayer
(
const
LayerConfig
&
config
)
:
Layer
(
config
)
{}
explicit
RecurrentLayer
(
const
LayerConfig
&
config
)
:
Layer
(
config
)
{}
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
void
forward
(
PassType
passType
);
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
);
void
backward
(
const
UpdateCallback
&
callback
)
override
;
void
resetState
();
void
resetState
()
override
;
void
setState
(
LayerStatePtr
state
);
void
setState
(
LayerStatePtr
state
)
override
;
LayerStatePtr
getState
();
LayerStatePtr
getState
()
override
;
protected:
protected:
/**
/**
...
...
paddle/gserver/layers/RecurrentLayerGroup.cpp
浏览文件 @
2859532d
...
@@ -33,15 +33,15 @@ public:
...
@@ -33,15 +33,15 @@ public:
void
initSubNetwork
(
NeuralNetwork
*
rootNetwork
,
void
initSubNetwork
(
NeuralNetwork
*
rootNetwork
,
const
ModelConfig
&
config
,
const
ModelConfig
&
config
,
const
std
::
vector
<
ParameterType
>&
parameterTypes
,
const
std
::
vector
<
ParameterType
>&
parameterTypes
,
bool
useGpu
);
bool
useGpu
)
override
;
void
forward
(
PassType
passType
)
{
void
forward
(
PassType
passType
)
override
{
REGISTER_TIMER_INFO
(
"RecurrentGroupFwTime"
,
getName
().
c_str
());
REGISTER_TIMER_INFO
(
"RecurrentGroupFwTime"
,
getName
().
c_str
());
const
std
::
vector
<
Argument
>
inArgs
;
const
std
::
vector
<
Argument
>
inArgs
;
std
::
vector
<
Argument
>
outArgs
;
std
::
vector
<
Argument
>
outArgs
;
network_
->
forward
(
inArgs
,
&
outArgs
,
passType
);
network_
->
forward
(
inArgs
,
&
outArgs
,
passType
);
}
}
void
backward
(
const
UpdateCallback
&
callback
)
{
void
backward
(
const
UpdateCallback
&
callback
)
override
{
REGISTER_TIMER_INFO
(
"RecurrentGroupBwTime"
,
getName
().
c_str
());
REGISTER_TIMER_INFO
(
"RecurrentGroupBwTime"
,
getName
().
c_str
());
network_
->
backward
(
nullptr
);
network_
->
backward
(
nullptr
);
...
@@ -53,7 +53,8 @@ public:
...
@@ -53,7 +53,8 @@ public:
/**
/**
* @see Layer.accessSubNetwork
* @see Layer.accessSubNetwork
*/
*/
void
accessSubNetwork
(
const
std
::
function
<
void
(
NeuralNetwork
&
)
>&
callback
)
{
void
accessSubNetwork
(
const
std
::
function
<
void
(
NeuralNetwork
&
)
>&
callback
)
override
{
callback
(
*
network_
);
callback
(
*
network_
);
}
}
...
...
paddle/gserver/layers/ResizeLayer.cpp
浏览文件 @
2859532d
...
@@ -20,18 +20,19 @@ namespace paddle {
...
@@ -20,18 +20,19 @@ namespace paddle {
/**
/**
* @brief A layer for resizing a minibatch matrix h*w to h'*w'
* @brief A layer for resizing a minibatch matrix h*w to h'*w'
* @note
* @note
* origin matrix height * wi
t
dth)
* origin matrix height * width)
* resize matrix: (height * width / size) * size
* resize matrix: (height * width / size) * size
*/
*/
class
ResizeLayer
:
public
Layer
{
class
ResizeLayer
:
public
Layer
{
public:
public:
explicit
ResizeLayer
(
const
LayerConfig
&
config
)
:
Layer
(
config
)
{}
explicit
ResizeLayer
(
const
LayerConfig
&
config
)
:
Layer
(
config
)
{}
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
void
forward
(
PassType
passType
);
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
);
void
backward
(
const
UpdateCallback
&
callback
)
override
;
};
};
REGISTER_LAYER
(
resize
,
ResizeLayer
);
REGISTER_LAYER
(
resize
,
ResizeLayer
);
...
...
paddle/gserver/layers/SamplingIdLayer.cpp
浏览文件 @
2859532d
...
@@ -35,8 +35,8 @@ public:
...
@@ -35,8 +35,8 @@ public:
explicit
SamplingIdLayer
(
const
LayerConfig
&
config
)
explicit
SamplingIdLayer
(
const
LayerConfig
&
config
)
:
Layer
(
config
),
rand1_
(
0
,
1
)
{}
:
Layer
(
config
),
rand1_
(
0
,
1
)
{}
virtual
bool
init
(
const
LayerMap
&
layerMap
,
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
{
const
ParameterMap
&
parameterMap
)
override
{
bool
ret
=
Layer
::
init
(
layerMap
,
parameterMap
);
bool
ret
=
Layer
::
init
(
layerMap
,
parameterMap
);
CHECK_EQ
(
1UL
,
inputLayers_
.
size
());
CHECK_EQ
(
1UL
,
inputLayers_
.
size
());
if
(
useGpu_
)
{
if
(
useGpu_
)
{
...
@@ -48,7 +48,7 @@ public:
...
@@ -48,7 +48,7 @@ public:
return
ret
;
return
ret
;
}
}
void
forward
(
PassType
passType
)
{
void
forward
(
PassType
passType
)
override
{
Layer
::
forward
(
passType
);
Layer
::
forward
(
passType
);
if
(
useGpu_
)
{
if
(
useGpu_
)
{
for
(
size_t
i
=
0
;
i
<
inputLayers_
.
size
();
i
++
)
{
for
(
size_t
i
=
0
;
i
<
inputLayers_
.
size
();
i
++
)
{
...
@@ -83,7 +83,7 @@ public:
...
@@ -83,7 +83,7 @@ public:
output_
.
ids
->
copyFrom
(
ids
.
data
(),
batchSize
);
output_
.
ids
->
copyFrom
(
ids
.
data
(),
batchSize
);
}
}
v
irtual
void
backward
(
const
UpdateCallback
&
callback
)
{}
v
oid
backward
(
const
UpdateCallback
&
callback
)
override
{}
};
};
REGISTER_LAYER
(
sampling_id
,
SamplingIdLayer
);
REGISTER_LAYER
(
sampling_id
,
SamplingIdLayer
);
...
...
paddle/gserver/layers/ScalingLayer.cpp
浏览文件 @
2859532d
...
@@ -37,10 +37,11 @@ public:
...
@@ -37,10 +37,11 @@ public:
~
ScalingLayer
()
{}
~
ScalingLayer
()
{}
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
void
forward
(
PassType
passType
);
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
);
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
override
;
};
};
REGISTER_LAYER
(
scaling
,
ScalingLayer
);
REGISTER_LAYER
(
scaling
,
ScalingLayer
);
...
...
paddle/gserver/layers/SelectiveFullyConnectedLayer.h
浏览文件 @
2859532d
...
@@ -65,9 +65,10 @@ public:
...
@@ -65,9 +65,10 @@ public:
:
Layer
(
config
),
selCols_
(
nullptr
)
{}
:
Layer
(
config
),
selCols_
(
nullptr
)
{}
~
SelectiveFullyConnectedLayer
()
{}
~
SelectiveFullyConnectedLayer
()
{}
void
prefetch
();
void
prefetch
()
override
;
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
Weight
&
getWeight
(
int
idx
)
{
return
*
weights_
[
idx
];
}
Weight
&
getWeight
(
int
idx
)
{
return
*
weights_
[
idx
];
}
...
@@ -90,8 +91,8 @@ public:
...
@@ -90,8 +91,8 @@ public:
void
fillSelectiveData
(
void
fillSelectiveData
(
const
std
::
shared_ptr
<
std
::
vector
<
std
::
pair
<
int
*
,
size_t
>>>&
candidates
);
const
std
::
shared_ptr
<
std
::
vector
<
std
::
pair
<
int
*
,
size_t
>>>&
candidates
);
void
forward
(
PassType
passType
);
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
);
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
override
;
private:
private:
/**
/**
...
...
paddle/gserver/layers/SequenceConcatLayer.cpp
浏览文件 @
2859532d
...
@@ -35,10 +35,11 @@ public:
...
@@ -35,10 +35,11 @@ public:
~
SequenceConcatLayer
()
{}
~
SequenceConcatLayer
()
{}
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
void
forward
(
PassType
passType
);
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
);
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
override
;
};
};
REGISTER_LAYER
(
seqconcat
,
SequenceConcatLayer
);
REGISTER_LAYER
(
seqconcat
,
SequenceConcatLayer
);
...
...
paddle/gserver/layers/SequenceLastInstanceLayer.cpp
浏览文件 @
2859532d
...
@@ -42,12 +42,11 @@ public:
...
@@ -42,12 +42,11 @@ public:
explicit
SequenceLastInstanceLayer
(
const
LayerConfig
&
config
)
explicit
SequenceLastInstanceLayer
(
const
LayerConfig
&
config
)
:
SequencePoolLayer
(
config
)
{}
:
SequencePoolLayer
(
config
)
{}
~
SequenceLastInstanceLayer
()
{}
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
override
;
void
forward
(
PassType
passType
);
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
);
};
};
REGISTER_LAYER
(
seqlastins
,
SequenceLastInstanceLayer
);
REGISTER_LAYER
(
seqlastins
,
SequenceLastInstanceLayer
);
...
...
paddle/gserver/layers/SequencePoolLayer.h
浏览文件 @
2859532d
...
@@ -46,12 +46,11 @@ protected:
...
@@ -46,12 +46,11 @@ protected:
public:
public:
explicit
SequencePoolLayer
(
const
LayerConfig
&
config
)
:
Layer
(
config
)
{}
explicit
SequencePoolLayer
(
const
LayerConfig
&
config
)
:
Layer
(
config
)
{}
virtual
~
SequencePoolLayer
()
{}
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
override
;
void
forward
(
PassType
passType
);
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
);
};
};
}
// namespace paddle
}
// namespace paddle
paddle/gserver/layers/SequenceReshapeLayer.cpp
浏览文件 @
2859532d
...
@@ -34,12 +34,11 @@ protected:
...
@@ -34,12 +34,11 @@ protected:
public:
public:
explicit
SequenceReshapeLayer
(
const
LayerConfig
&
config
)
:
Layer
(
config
)
{}
explicit
SequenceReshapeLayer
(
const
LayerConfig
&
config
)
:
Layer
(
config
)
{}
~
SequenceReshapeLayer
()
{}
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
override
;
void
forward
(
PassType
passType
);
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
);
};
};
REGISTER_LAYER
(
seqreshape
,
SequenceReshapeLayer
);
REGISTER_LAYER
(
seqreshape
,
SequenceReshapeLayer
);
...
...
paddle/gserver/layers/SlopeInterceptLayer.cpp
浏览文件 @
2859532d
...
@@ -39,12 +39,11 @@ class SlopeInterceptLayer : public Layer {
...
@@ -39,12 +39,11 @@ class SlopeInterceptLayer : public Layer {
public:
public:
explicit
SlopeInterceptLayer
(
const
LayerConfig
&
config
)
:
Layer
(
config
)
{}
explicit
SlopeInterceptLayer
(
const
LayerConfig
&
config
)
:
Layer
(
config
)
{}
~
SlopeInterceptLayer
()
{}
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
override
;
void
forward
(
PassType
passType
);
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
);
};
};
REGISTER_LAYER
(
slope_intercept
,
SlopeInterceptLayer
);
REGISTER_LAYER
(
slope_intercept
,
SlopeInterceptLayer
);
...
...
paddle/gserver/layers/SpatialPyramidPoolLayer.h
浏览文件 @
2859532d
...
@@ -43,9 +43,8 @@ protected:
...
@@ -43,9 +43,8 @@ protected:
public:
public:
explicit
SpatialPyramidPoolLayer
(
const
LayerConfig
&
config
)
:
Layer
(
config
)
{}
explicit
SpatialPyramidPoolLayer
(
const
LayerConfig
&
config
)
:
Layer
(
config
)
{}
~
SpatialPyramidPoolLayer
()
{}
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
virtual
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
ProjectionConfig
getConfig
(
size_t
sizeX_
,
ProjectionConfig
getConfig
(
size_t
sizeX_
,
size_t
sizeY_
,
size_t
sizeY_
,
...
@@ -54,7 +53,7 @@ public:
...
@@ -54,7 +53,7 @@ public:
std
::
string
&
poolType_
);
std
::
string
&
poolType_
);
size_t
getSize
();
size_t
getSize
();
v
irtual
void
forward
(
PassType
passType
)
;
v
oid
forward
(
PassType
passType
)
override
;
v
irtual
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
;
v
oid
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
override
;
};
};
}
// namespace paddle
}
// namespace paddle
paddle/gserver/layers/SubSequenceLayer.cpp
浏览文件 @
2859532d
...
@@ -35,12 +35,11 @@ protected:
...
@@ -35,12 +35,11 @@ protected:
public:
public:
explicit
SubSequenceLayer
(
const
LayerConfig
&
config
)
:
Layer
(
config
)
{}
explicit
SubSequenceLayer
(
const
LayerConfig
&
config
)
:
Layer
(
config
)
{}
~
SubSequenceLayer
()
{}
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
override
;
void
forward
(
PassType
passType
);
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
);
};
};
REGISTER_LAYER
(
subseq
,
SubSequenceLayer
);
REGISTER_LAYER
(
subseq
,
SubSequenceLayer
);
...
...
paddle/gserver/layers/SumToOneNormLayer.cpp
浏览文件 @
2859532d
...
@@ -41,12 +41,11 @@ protected:
...
@@ -41,12 +41,11 @@ protected:
public:
public:
explicit
SumToOneNormLayer
(
const
LayerConfig
&
config
)
:
Layer
(
config
)
{}
explicit
SumToOneNormLayer
(
const
LayerConfig
&
config
)
:
Layer
(
config
)
{}
~
SumToOneNormLayer
()
{}
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
override
;
void
forward
(
PassType
passType
);
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
);
};
};
REGISTER_LAYER
(
sum_to_one_norm
,
SumToOneNormLayer
);
REGISTER_LAYER
(
sum_to_one_norm
,
SumToOneNormLayer
);
...
...
paddle/gserver/layers/TensorLayer.h
浏览文件 @
2859532d
...
@@ -44,13 +44,12 @@ protected:
...
@@ -44,13 +44,12 @@ protected:
public:
public:
explicit
TensorLayer
(
const
LayerConfig
&
config
)
:
Layer
(
config
)
{}
explicit
TensorLayer
(
const
LayerConfig
&
config
)
:
Layer
(
config
)
{}
~
TensorLayer
()
{}
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
Weight
&
getWeight
(
int
idx
)
{
return
*
weights_
[
idx
];
}
Weight
&
getWeight
(
int
idx
)
{
return
*
weights_
[
idx
];
}
void
forward
(
PassType
passType
);
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
);
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
override
;
};
};
}
// namespace paddle
}
// namespace paddle
paddle/gserver/layers/TransLayer.h
浏览文件 @
2859532d
...
@@ -32,9 +32,10 @@ class TransLayer : public Layer {
...
@@ -32,9 +32,10 @@ class TransLayer : public Layer {
public:
public:
explicit
TransLayer
(
const
LayerConfig
&
config
)
:
Layer
(
config
)
{}
explicit
TransLayer
(
const
LayerConfig
&
config
)
:
Layer
(
config
)
{}
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
void
forward
(
PassType
passType
);
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
);
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
override
;
};
};
}
// namespace paddle
}
// namespace paddle
paddle/gserver/layers/ValidationLayer.h
浏览文件 @
2859532d
...
@@ -26,7 +26,8 @@ class ValidationLayer : public Layer {
...
@@ -26,7 +26,8 @@ class ValidationLayer : public Layer {
public:
public:
explicit
ValidationLayer
(
const
LayerConfig
&
config
)
:
Layer
(
config
)
{}
explicit
ValidationLayer
(
const
LayerConfig
&
config
)
:
Layer
(
config
)
{}
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
LayerPtr
getOutputLayer
()
{
return
inputLayers_
[
0
];
}
LayerPtr
getOutputLayer
()
{
return
inputLayers_
[
0
];
}
...
@@ -37,13 +38,13 @@ public:
...
@@ -37,13 +38,13 @@ public:
return
inputLayers_
[
2
];
return
inputLayers_
[
2
];
}
}
v
irtual
void
forward
(
PassType
passType
)
;
v
oid
forward
(
PassType
passType
)
override
;
v
irtual
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
;
v
oid
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
override
;
virtual
void
validationImp
(
MatrixPtr
outputValue
,
IVectorPtr
label
)
=
0
;
virtual
void
validationImp
(
MatrixPtr
outputValue
,
IVectorPtr
label
)
=
0
;
v
irtual
void
onPassEnd
()
=
0
;
v
oid
onPassEnd
()
override
=
0
;
};
};
/*
/*
...
@@ -57,11 +58,12 @@ public:
...
@@ -57,11 +58,12 @@ public:
cpuLabel_
(
nullptr
),
cpuLabel_
(
nullptr
),
cpuWeight_
(
nullptr
)
{}
cpuWeight_
(
nullptr
)
{}
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
void
validationImp
(
MatrixPtr
outputValue
,
IVectorPtr
label
);
void
validationImp
(
MatrixPtr
outputValue
,
IVectorPtr
label
)
override
;
void
onPassEnd
();
void
onPassEnd
()
override
;
struct
PredictionResult
{
struct
PredictionResult
{
PredictionResult
(
real
__out
,
int
__label
)
:
out
(
__out
),
label
(
__label
)
{}
PredictionResult
(
real
__out
,
int
__label
)
:
out
(
__out
),
label
(
__label
)
{}
...
@@ -86,11 +88,12 @@ public:
...
@@ -86,11 +88,12 @@ public:
explicit
PnpairValidation
(
const
LayerConfig
&
config
)
explicit
PnpairValidation
(
const
LayerConfig
&
config
)
:
ValidationLayer
(
config
)
{}
:
ValidationLayer
(
config
)
{}
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
void
validationImp
(
MatrixPtr
outputValue
,
IVectorPtr
label
);
void
validationImp
(
MatrixPtr
outputValue
,
IVectorPtr
label
)
override
;
void
onPassEnd
();
void
onPassEnd
()
override
;
private:
private:
bool
passBegin_
;
bool
passBegin_
;
...
...
paddle/gserver/layers/WarpCTCLayer.h
浏览文件 @
2859532d
...
@@ -30,9 +30,10 @@ public:
...
@@ -30,9 +30,10 @@ public:
explicit
WarpCTCLayer
(
const
LayerConfig
&
config
)
:
Layer
(
config
)
{}
explicit
WarpCTCLayer
(
const
LayerConfig
&
config
)
:
Layer
(
config
)
{}
~
WarpCTCLayer
()
{}
~
WarpCTCLayer
()
{}
virtual
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
bool
init
(
const
LayerMap
&
layerMap
,
virtual
void
forward
(
PassType
passType
);
const
ParameterMap
&
parameterMap
)
override
;
virtual
void
backward
(
const
UpdateCallback
&
callback
);
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
)
override
;
protected:
protected:
/**
/**
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录