Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
机器未来
Paddle
提交
ed808f5e
P
Paddle
项目概览
机器未来
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
ed808f5e
编写于
2月 03, 2017
作者:
Y
Yu Yang
提交者:
GitHub
2月 03, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1251 from reyoung/feature/add_override_to_layer_init
Using override keyword in Layer
上级
b9dfe8e7
e7419d69
变更
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
浏览文件 @
ed808f5e
...
...
@@ -155,7 +155,8 @@ protected:
public:
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
(
biasParameter_
)
{
...
...
@@ -174,7 +175,7 @@ public:
}
}
v
irtual
void
forward
(
PassType
passType
)
{
v
oid
forward
(
PassType
passType
)
override
{
if
(
biases_
)
{
MatrixPtr
outV
=
getOutputValue
();
outV
->
addBias
(
*
(
biases_
->
getW
()),
1
);
...
...
@@ -182,7 +183,7 @@ public:
}
}
v
irtual
void
backward
(
const
UpdateCallback
&
callback
)
{
v
oid
backward
(
const
UpdateCallback
&
callback
)
override
{
if
(
biases_
)
{
backwardActivation
();
biases_
->
getWGrad
()
->
collectBias
(
*
getOutputGrad
(),
1
);
...
...
paddle/gserver/layers/AddtoLayer.h
浏览文件 @
ed808f5e
...
...
@@ -44,19 +44,20 @@ public:
/**
* Intialization of AddtoLayer.
*/
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
/**
* Forward propagation.
* @note There is no weight matrix for each input,
* because it just a simple add operation.
*/
void
forward
(
PassType
passType
);
void
forward
(
PassType
passType
)
override
;
/**
* Backward propagation.
*/
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
);
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
override
;
};
}
// namespace paddle
paddle/gserver/layers/AgentLayer.h
浏览文件 @
ed808f5e
...
...
@@ -35,7 +35,8 @@ public:
~
AgentLayer
()
{}
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
// if *numSamples* set,
// real layer output will only use first *numSamples* rows
...
...
@@ -44,8 +45,8 @@ public:
numSamples_
=
numSamples
;
}
void
forward
(
PassType
passType
);
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
{}
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
override
{}
};
/**
...
...
@@ -56,8 +57,8 @@ public:
explicit
SequenceAgentLayer
(
const
LayerConfig
&
config
)
:
AgentLayer
(
config
)
{}
~
SequenceAgentLayer
()
{}
void
forward
(
PassType
passType
);
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
{}
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
override
{}
};
/**
...
...
@@ -78,7 +79,8 @@ public:
virtual
~
GatherAgentLayer
()
{}
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
// call before addRealLayer
void
copyIdAndSequenceInfo
(
const
Argument
&
input
,
...
...
@@ -88,8 +90,8 @@ public:
// add one real layer, can call many times
void
addRealLayer
(
LayerPtr
layer
)
{
realLayers_
.
push_back
(
layer
);
}
void
forward
(
PassType
passType
);
void
backward
(
const
UpdateCallback
&
callback
);
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
)
override
;
};
/**
...
...
@@ -133,7 +135,8 @@ public:
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
...
...
@@ -182,8 +185,8 @@ public:
numSequences_
=
numSequences
;
}
void
forward
(
PassType
passType
);
void
backward
(
const
UpdateCallback
&
callback
);
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
)
override
;
};
/**
...
...
paddle/gserver/layers/AverageLayer.h
浏览文件 @
ed808f5e
...
...
@@ -38,12 +38,11 @@ public:
explicit
AverageLayer
(
const
LayerConfig
&
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
);
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
);
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
override
;
protected:
MatrixPtr
outMtx_
;
...
...
paddle/gserver/layers/BatchNormBaseLayer.h
浏览文件 @
ed808f5e
...
...
@@ -52,7 +52,8 @@ public:
*/
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
...
...
paddle/gserver/layers/BatchNormalizationLayer.h
浏览文件 @
ed808f5e
...
...
@@ -33,9 +33,10 @@ public:
~
BatchNormalizationLayer
()
{}
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
void
forward
(
PassType
passType
);
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
);
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
override
;
protected:
/// Epsilon value used in the batch normalization formula.
...
...
@@ -58,7 +59,7 @@ protected:
/// to batch, channels* imagePixels.
void
shrinkMat
(
const
MatrixPtr
&
in
,
MatrixPtr
&
out
);
void
onPassEnd
()
{
firstTest_
=
true
;
}
void
onPassEnd
()
override
{
firstTest_
=
true
;
}
MatrixPtr
tmpMat_
,
tmpGrad_
;
MatrixPtr
expandedIn_
,
expandedOut_
;
...
...
paddle/gserver/layers/BilinearInterpLayer.h
浏览文件 @
ed808f5e
...
...
@@ -38,9 +38,10 @@ public:
virtual
~
BilinearInterpLayer
()
{}
size_t
getSize
();
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
void
forward
(
PassType
passType
);
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
);
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
override
;
};
}
// namespace paddle
paddle/gserver/layers/BlockExpandLayer.h
浏览文件 @
ed808f5e
...
...
@@ -58,10 +58,11 @@ public:
~
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
irtual
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
;
v
oid
forward
(
PassType
passType
)
override
;
v
oid
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
override
;
};
}
// namespace paddle
paddle/gserver/layers/CRFDecodingLayer.h
浏览文件 @
ed808f5e
...
...
@@ -32,9 +32,10 @@ namespace paddle {
class
CRFDecodingLayer
:
public
CRFLayer
{
public:
explicit
CRFDecodingLayer
(
const
LayerConfig
&
config
)
:
CRFLayer
(
config
)
{}
virtual
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
virtual
void
forward
(
PassType
passType
);
virtual
void
backward
(
const
UpdateCallback
&
callback
);
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
)
override
;
protected:
std
::
unique_ptr
<
LinearChainCRF
>
crf_
;
...
...
paddle/gserver/layers/CRFLayer.h
浏览文件 @
ed808f5e
...
...
@@ -29,9 +29,10 @@ namespace paddle {
class
CRFLayer
:
public
Layer
{
public:
explicit
CRFLayer
(
const
LayerConfig
&
config
)
:
Layer
(
config
)
{}
virtual
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
virtual
void
forward
(
PassType
passType
);
virtual
void
backward
(
const
UpdateCallback
&
callback
);
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
)
override
;
protected:
size_t
numClasses_
;
...
...
paddle/gserver/layers/CTCLayer.h
浏览文件 @
ed808f5e
...
...
@@ -22,10 +22,11 @@ namespace paddle {
class
CTCLayer
:
public
Layer
{
public:
explicit
CTCLayer
(
const
LayerConfig
&
config
)
:
Layer
(
config
)
{}
virtual
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
virtual
void
forward
(
PassType
passType
);
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
void
forward
(
PassType
passType
)
override
;
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
,
const
Argument
&
softmaxSeqs
,
const
Argument
&
labelSeqs
);
...
...
paddle/gserver/layers/ConcatenateLayer.cpp
浏览文件 @
ed808f5e
...
...
@@ -28,10 +28,11 @@ public:
~
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
irtual
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
;
v
oid
forward
(
PassType
passType
)
override
;
v
oid
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
override
;
};
REGISTER_LAYER
(
concat
,
ConcatenateLayer
);
...
...
@@ -101,10 +102,11 @@ public:
~
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
irtual
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
;
v
oid
forward
(
PassType
passType
)
override
;
v
oid
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
override
;
protected:
std
::
vector
<
std
::
unique_ptr
<
Projection
>>
projections_
;
...
...
paddle/gserver/layers/ConvBaseLayer.h
浏览文件 @
ed808f5e
...
...
@@ -80,7 +80,8 @@ protected:
public:
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
...
...
paddle/gserver/layers/ConvShiftLayer.cpp
浏览文件 @
ed808f5e
...
...
@@ -47,10 +47,11 @@ public:
~
ConvShiftLayer
()
{}
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
void
forward
(
PassType
passType
);
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
);
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
override
;
};
REGISTER_LAYER
(
conv_shift
,
ConvShiftLayer
);
...
...
paddle/gserver/layers/ConvexCombinationLayer.cpp
浏览文件 @
ed808f5e
...
...
@@ -49,10 +49,11 @@ public:
~
ConvexCombinationLayer
()
{}
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
void
forward
(
PassType
passType
);
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
);
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
override
;
};
REGISTER_LAYER
(
convex_comb
,
ConvexCombinationLayer
);
...
...
paddle/gserver/layers/CosSimLayer.h
浏览文件 @
ed808f5e
...
...
@@ -38,10 +38,11 @@ public:
~
CosSimLayer
()
{}
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
void
forward
(
PassType
passType
);
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
);
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
override
;
};
}
// namespace paddle
paddle/gserver/layers/CosSimVecMatLayer.cpp
浏览文件 @
ed808f5e
...
...
@@ -46,10 +46,11 @@ public:
~
CosSimVecMatLayer
()
{}
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
void
forward
(
PassType
passType
);
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
);
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
override
;
};
REGISTER_LAYER
(
cos_vm
,
CosSimVecMatLayer
);
...
...
paddle/gserver/layers/CostLayer.cpp
浏览文件 @
ed808f5e
...
...
@@ -367,8 +367,6 @@ void LambdaCost::backward(const UpdateCallback& callback) {
getInputGrad
(
0
)
->
add
(
*
marginGrad_
);
}
void
LambdaCost
::
onPassEnd
()
{}
void
LambdaCost
::
calcGrad
(
const
real
*
outputScore
,
const
real
*
score
,
real
*
gradData
,
...
...
@@ -611,14 +609,15 @@ class SumCostLayer : public Layer {
public:
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
);
if
(
!
ret
)
return
ret
;
CHECK_EQ
(
inputLayers_
.
size
(),
1UL
);
return
true
;
}
v
irtual
void
forward
(
PassType
passType
)
{
v
oid
forward
(
PassType
passType
)
override
{
Layer
::
forward
(
passType
);
const
MatrixPtr
&
input
=
getInputValue
(
0
);
...
...
@@ -629,7 +628,7 @@ public:
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
);
}
};
...
...
paddle/gserver/layers/CostLayer.h
浏览文件 @
ed808f5e
...
...
@@ -32,15 +32,16 @@ class CostLayer : public Layer {
public:
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
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
,
Argument
&
label
,
...
...
@@ -68,11 +69,14 @@ public:
explicit
MultiClassCrossEntropy
(
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
backwardImp
(
Matrix
&
outputValue
,
Argument
&
label
,
Matrix
&
outputGrad
);
void
backwardImp
(
Matrix
&
outputValue
,
Argument
&
label
,
Matrix
&
outputGrad
)
override
;
};
/**
...
...
@@ -95,11 +99,14 @@ public:
explicit
MultiClassCrossEntropyWithSelfNorm
(
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
backwardImp
(
Matrix
&
outputValue
,
Argument
&
label
,
Matrix
&
outputGrad
);
void
backwardImp
(
Matrix
&
outputValue
,
Argument
&
label
,
Matrix
&
outputGrad
)
override
;
protected:
MatrixPtr
sftMaxSum_
;
...
...
@@ -117,11 +124,14 @@ public:
explicit
SoftBinaryClassCrossEntropy
(
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
backwardImp
(
Matrix
&
outputValue
,
Argument
&
label
,
Matrix
&
outputGrad
);
void
backwardImp
(
Matrix
&
outputValue
,
Argument
&
label
,
Matrix
&
outputGrad
)
override
;
protected:
MatrixPtr
targetPerDim_
;
...
...
@@ -139,11 +149,14 @@ public:
explicit
SumOfSquaresCostLayer
(
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
backwardImp
(
Matrix
&
outputValue
,
Argument
&
label
,
Matrix
&
outputGrad
);
void
backwardImp
(
Matrix
&
outputValue
,
Argument
&
label
,
Matrix
&
outputGrad
)
override
;
};
/**
...
...
@@ -162,17 +175,18 @@ class RankingCost : public Layer {
public:
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
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
)
output
;
...
...
@@ -214,17 +228,16 @@ class LambdaCost : public Layer {
public:
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
getScoreLayer
()
{
return
inputLayers_
[
1
];
}
void
forward
(
PassType
passType
);
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
);
void
onPassEnd
();
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
override
;
real
calcNDCG
(
const
real
*
outputScore
,
const
real
*
score
,
int
size
);
void
calcGrad
(
const
real
*
outputScore
,
...
...
@@ -256,11 +269,14 @@ public:
explicit
MultiBinaryLabelCrossEntropy
(
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
backwardImp
(
Matrix
&
outputValue
,
Argument
&
label
,
Matrix
&
outputGrad
);
void
backwardImp
(
Matrix
&
outputValue
,
Argument
&
label
,
Matrix
&
outputGrad
)
override
;
};
/**
...
...
@@ -282,13 +298,16 @@ class HuberTwoClass : public CostLayer {
public:
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
backwardImp
(
Matrix
&
outputValue
,
Argument
&
label
,
Matrix
&
outputGrad
);
void
backwardImp
(
Matrix
&
outputValue
,
Argument
&
label
,
Matrix
&
outputGrad
)
override
;
void
backwardImpIn
(
Matrix
&
outputValue
,
Argument
&
label
,
Matrix
&
outputGrad
);
};
...
...
paddle/gserver/layers/CudnnBatchNormLayer.h
浏览文件 @
ed808f5e
...
...
@@ -35,14 +35,15 @@ public:
~
CudnnBatchNormLayer
();
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
/**
* reshape tensor of ioDesc_.
*/
void
reshape
(
int
batchSize
);
void
forward
(
PassType
passType
);
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
);
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
override
;
protected:
/**
...
...
paddle/gserver/layers/CudnnConvLayer.h
浏览文件 @
ed808f5e
...
...
@@ -45,9 +45,10 @@ public:
~
CudnnConvLayer
();
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
void
forward
(
PassType
passType
);
void
backward
(
const
UpdateCallback
&
callback
);
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
)
override
;
void
addBiases
();
void
bpropBiases
();
};
...
...
paddle/gserver/layers/CudnnPoolLayer.h
浏览文件 @
ed808f5e
...
...
@@ -45,7 +45,8 @@ public:
hl_pooling_mode_t
*
mode
=
nullptr
);
explicit
CudnnPoolLayer
(
const
LayerConfig
&
config
);
~
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.
...
...
@@ -53,8 +54,8 @@ public:
* So reshaping is needed.
*/
void
reshape
(
int
batchSize
);
v
irtual
void
forward
(
PassType
passType
)
;
v
irtual
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
;
v
oid
forward
(
PassType
passType
)
override
;
v
oid
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
override
;
};
}
// namespace paddle
paddle/gserver/layers/DataLayer.h
浏览文件 @
ed808f5e
...
...
@@ -33,13 +33,13 @@ public:
/**
* Prefetch sparse matrix/ids only.
*/
void
prefetch
()
{
output_
=
data_
;
}
void
prefetch
()
override
{
output_
=
data_
;
}
/**
* Forward propagation. Copy data_ (value, in, grad, ids, cpuSequenceDims,
* sequenceStartPositions, subSequenceStartPositions, strs) to output_.
*/
v
irtual
void
forward
(
PassType
passType
)
{
v
oid
forward
(
PassType
passType
)
override
{
Layer
::
forward
(
passType
);
copyDataToOutput
(
output_
);
if
(
FLAGS_show_layer_stat
)
{
...
...
@@ -50,9 +50,9 @@ public:
/**
* 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
++
)
{
copyDataToOutput
(
outputOtherDevice_
[
i
]);
}
...
...
paddle/gserver/layers/DataNormLayer.h
浏览文件 @
ed808f5e
...
...
@@ -44,10 +44,11 @@ public:
~
DataNormLayer
()
{}
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
void
forward
(
PassType
passType
);
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
);
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
override
;
protected:
int
mode_
;
...
...
paddle/gserver/layers/EosIdCheckLayer.cpp
浏览文件 @
ed808f5e
...
...
@@ -27,14 +27,14 @@ class EosIdCheckLayer : public Layer {
public:
explicit
EosIdCheckLayer
(
const
LayerConfig
&
config
)
:
Layer
(
config
)
{}
virtual
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
{
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
{
bool
ret
=
Layer
::
init
(
layerMap
,
parameterMap
);
CHECK_EQ
(
1UL
,
inputLayers_
.
size
());
return
ret
;
}
v
irtual
void
forward
(
PassType
passType
)
{
v
oid
forward
(
PassType
passType
)
override
{
Layer
::
forward
(
passType
);
const
Argument
&
input
=
getInput
(
0
);
...
...
@@ -42,7 +42,7 @@ public:
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
);
...
...
paddle/gserver/layers/ExpandConvBaseLayer.h
浏览文件 @
ed808f5e
...
...
@@ -48,7 +48,8 @@ public:
~
ExpandConvBaseLayer
()
{}
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
size_t
getOutputSize
();
/**
...
...
paddle/gserver/layers/ExpandConvLayer.h
浏览文件 @
ed808f5e
...
...
@@ -35,10 +35,11 @@ public:
~
ExpandConvLayer
()
{}
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
void
forward
(
PassType
passType
);
void
backward
(
const
UpdateCallback
&
callback
);
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
)
override
;
};
}
// namespace paddle
paddle/gserver/layers/ExpandConvTransLayer.h
浏览文件 @
ed808f5e
...
...
@@ -34,10 +34,11 @@ public:
~
ExpandConvTransLayer
()
{}
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
void
forward
(
PassType
passType
);
void
backward
(
const
UpdateCallback
&
callback
);
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
)
override
;
};
}
// namespace paddle
paddle/gserver/layers/ExpandLayer.h
浏览文件 @
ed808f5e
...
...
@@ -53,10 +53,11 @@ public:
~
ExpandLayer
()
{}
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
void
forward
(
PassType
passType
);
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
);
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
override
;
};
}
// namespace paddle
paddle/gserver/layers/FeatureMapExpandLayer.cpp
浏览文件 @
ed808f5e
...
...
@@ -46,10 +46,11 @@ public:
~
FeatureMapExpandLayer
()
{}
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
void
forward
(
PassType
passType
);
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
);
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
override
;
};
REGISTER_LAYER
(
featmap_expand
,
FeatureMapExpandLayer
);
...
...
paddle/gserver/layers/FullyConnectedLayer.h
浏览文件 @
ed808f5e
...
...
@@ -36,13 +36,14 @@ public:
explicit
FullyConnectedLayer
(
const
LayerConfig
&
config
)
:
Layer
(
config
)
{}
~
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
];
}
void
prefetch
();
void
forward
(
PassType
passType
);
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
);
void
prefetch
()
override
;
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
override
;
};
}
// namespace paddle
paddle/gserver/layers/GatedRecurrentLayer.h
浏览文件 @
ed808f5e
...
...
@@ -50,17 +50,18 @@ class GatedRecurrentLayer : public Layer, public GruCompute {
public:
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:
void
forwardSequence
(
int
batchSize
,
...
...
paddle/gserver/layers/GetOutputLayer.cpp
浏览文件 @
ed808f5e
...
...
@@ -22,17 +22,18 @@ public:
~
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
;
CHECK_EQ
(
1U
,
inputLayers_
.
size
());
CHECK_NE
(
inputArgument_
[
0
],
""
);
return
true
;
}
void
forward
(
PassType
passType
)
{
void
forward
(
PassType
passType
)
override
{
output_
=
getPrev
(
0
)
->
getOutput
(
inputArgument_
[
0
]);
}
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
{}
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
override
{}
};
REGISTER_LAYER
(
get_output
,
GetOutputLayer
);
...
...
paddle/gserver/layers/GruStepLayer.cpp
浏览文件 @
ed808f5e
...
...
@@ -55,10 +55,11 @@ public:
~
GruStepLayer
()
{}
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
void
forward
(
PassType
passType
);
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
);
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
override
;
};
REGISTER_LAYER
(
gru_step
,
GruStepLayer
);
...
...
paddle/gserver/layers/HierarchicalSigmoidLayer.h
浏览文件 @
ed808f5e
...
...
@@ -61,9 +61,10 @@ class HierarchicalSigmoidLayer : public Layer {
public:
explicit
HierarchicalSigmoidLayer
(
const
LayerConfig
&
config
)
:
Layer
(
config
)
{}
virtual
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
virtual
void
forward
(
PassType
passType
);
virtual
void
backward
(
const
UpdateCallback
&
callback
);
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
)
override
;
protected:
/**
...
...
paddle/gserver/layers/InterpolationLayer.cpp
浏览文件 @
ed808f5e
...
...
@@ -43,10 +43,11 @@ public:
~
InterpolationLayer
()
{}
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
void
forward
(
PassType
passType
);
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
);
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
override
;
};
REGISTER_LAYER
(
interpolation
,
InterpolationLayer
);
...
...
paddle/gserver/layers/LstmLayer.h
浏览文件 @
ed808f5e
...
...
@@ -74,17 +74,18 @@ class LstmLayer : public Layer, public LstmCompute {
public:
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:
/**
...
...
paddle/gserver/layers/LstmStepLayer.cpp
浏览文件 @
ed808f5e
...
...
@@ -35,10 +35,11 @@ public:
~
LstmStepLayer
()
{}
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
void
forward
(
PassType
passType
);
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
);
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
override
;
};
REGISTER_LAYER
(
lstm_step
,
LstmStepLayer
);
...
...
paddle/gserver/layers/MDLstmLayer.cpp
浏览文件 @
ed808f5e
...
...
@@ -181,11 +181,12 @@ class MDLstmLayer : public LstmLayer {
public:
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:
void
forwardOneSequence
(
int
start
,
CoordIterator
&
coordIter
);
...
...
paddle/gserver/layers/MaxIdLayer.cpp
浏览文件 @
ed808f5e
...
...
@@ -30,8 +30,8 @@ private:
public:
explicit
MaxIdLayer
(
const
LayerConfig
&
config
)
:
Layer
(
config
)
{}
virtual
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
{
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
{
bool
ret
=
Layer
::
init
(
layerMap
,
parameterMap
);
CHECK_EQ
(
1UL
,
inputLayers_
.
size
());
...
...
@@ -40,7 +40,7 @@ public:
return
ret
;
}
v
irtual
void
forward
(
PassType
passType
)
{
v
oid
forward
(
PassType
passType
)
override
{
Layer
::
forward
(
passType
);
const
Argument
&
input
=
getInput
(
0
);
size_t
batchSize
=
input
.
getBatchSize
();
...
...
@@ -54,7 +54,7 @@ public:
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
);
...
...
paddle/gserver/layers/MaxLayer.h
浏览文件 @
ed808f5e
...
...
@@ -42,14 +42,13 @@ protected:
public:
explicit
MaxLayer
(
const
LayerConfig
&
config
)
:
SequencePoolLayer
(
config
)
{}
~
MaxLayer
()
{}
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
{
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
{
return
SequencePoolLayer
::
init
(
layerMap
,
parameterMap
);
}
void
forward
(
PassType
passType
);
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
);
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
override
;
};
}
// namespace paddle
paddle/gserver/layers/MaxOutLayer.h
浏览文件 @
ed808f5e
...
...
@@ -45,10 +45,11 @@ public:
explicit
MaxOutLayer
(
const
LayerConfig
&
config
)
:
Layer
(
config
)
{}
virtual
~
MaxOutLayer
()
{}
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
void
forward
(
PassType
passType
);
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
);
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
override
;
};
}
// namespace paddle
paddle/gserver/layers/MixedLayer.h
浏览文件 @
ed808f5e
...
...
@@ -35,21 +35,22 @@ public:
~
MixedLayer
()
{}
virtual
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
v
irtual
void
prefetch
()
;
v
irtual
void
forward
(
PassType
passType
)
;
v
irtual
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
;
v
irtual
void
resetState
()
;
v
oid
prefetch
()
override
;
v
oid
forward
(
PassType
passType
)
override
;
v
oid
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
override
;
v
oid
resetState
()
override
;
/**
* setState() should be called after getState().
* 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.
*/
virtual
LayerStatePtr
getState
()
;
LayerStatePtr
getState
()
override
;
protected:
std
::
vector
<
std
::
unique_ptr
<
Projection
>>
projections_
;
...
...
paddle/gserver/layers/MultiplexLayer.cpp
浏览文件 @
ed808f5e
...
...
@@ -69,10 +69,11 @@ public:
~
MultiplexLayer
()
{}
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
void
forward
(
PassType
passType
);
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
);
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
override
;
private:
/**
...
...
paddle/gserver/layers/NCELayer.cpp
浏览文件 @
ed808f5e
...
...
@@ -61,7 +61,8 @@ public:
rand_
(
0
,
config
.
num_classes
()
-
1
),
prepared_
(
false
)
{}
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
{
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
{
/* Initialize the basic parent class */
Layer
::
init
(
layerMap
,
parameterMap
);
...
...
@@ -146,7 +147,7 @@ public:
prepared_
=
true
;
}
void
prefetch
()
{
void
prefetch
()
override
{
prepareSamples
();
IVector
::
resizeOrCreate
(
labelIds_
,
samples_
.
size
(),
useGpu_
);
int
*
ids
=
labelIds_
->
getData
();
...
...
@@ -163,7 +164,7 @@ public:
}
}
void
forward
(
PassType
passType
)
{
void
forward
(
PassType
passType
)
override
{
Layer
::
forward
(
passType
);
CHECK
(
!
useGpu_
)
<<
"GPU is not supported"
;
...
...
@@ -199,7 +200,7 @@ public:
forwardCost
();
}
void
backward
(
const
UpdateCallback
&
callback
)
{
void
backward
(
const
UpdateCallback
&
callback
)
override
{
Matrix
::
resizeOrCreate
(
sampleOut_
.
grad
,
1
,
samples_
.
size
(),
...
...
paddle/gserver/layers/NormLayer.h
浏览文件 @
ed808f5e
...
...
@@ -30,7 +30,8 @@ class NormLayer : public Layer {
public:
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
);
return
true
;
}
...
...
@@ -56,9 +57,10 @@ protected:
public:
explicit
ResponseNormLayer
(
const
LayerConfig
&
config
)
:
NormLayer
(
config
)
{}
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
void
forward
(
PassType
passType
)
{
LOG
(
FATAL
)
<<
"Not implemented"
;
}
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
{
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
void
forward
(
PassType
passType
)
override
{
LOG
(
FATAL
)
<<
"Not implemented"
;
}
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
override
{
LOG
(
FATAL
)
<<
"Not implemented"
;
}
};
...
...
paddle/gserver/layers/NormProjectionLayer.h
浏览文件 @
ed808f5e
...
...
@@ -36,9 +36,10 @@ public:
size_t
getSize
();
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
void
forward
(
PassType
passType
);
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
);
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
override
;
protected:
TensorShape
shape_
;
...
...
paddle/gserver/layers/OuterProdLayer.cpp
浏览文件 @
ed808f5e
...
...
@@ -38,10 +38,11 @@ public:
~
OuterProdLayer
()
{}
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
void
forward
(
PassType
passType
);
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
);
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
override
;
};
REGISTER_LAYER
(
out_prod
,
OuterProdLayer
);
...
...
paddle/gserver/layers/PadLayer.h
浏览文件 @
ed808f5e
...
...
@@ -29,9 +29,10 @@ public:
~
PadLayer
()
{}
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
void
forward
(
PassType
passType
);
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
);
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
override
;
protected:
void
setOutDims
(
const
size_t
batchSize
);
...
...
paddle/gserver/layers/ParameterReluLayer.h
浏览文件 @
ed808f5e
...
...
@@ -56,9 +56,10 @@ public:
~
ParameterReluLayer
()
{}
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
void
forward
(
PassType
passType
);
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
);
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
override
;
};
}
// namespace paddle
paddle/gserver/layers/PoolLayer.h
浏览文件 @
ed808f5e
...
...
@@ -46,7 +46,8 @@ public:
*/
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
paddle/gserver/layers/PoolProjectionLayer.h
浏览文件 @
ed808f5e
...
...
@@ -40,7 +40,7 @@ public:
size_t
getSize
();
v
irtual
void
forward
(
PassType
passType
)
;
v
irtual
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
;
v
oid
forward
(
PassType
passType
)
override
;
v
oid
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
override
;
};
}
// namespace paddle
paddle/gserver/layers/PowerLayer.cpp
浏览文件 @
ed808f5e
...
...
@@ -40,10 +40,11 @@ public:
~
PowerLayer
()
{}
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
void
forward
(
PassType
passType
);
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
);
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
override
;
};
REGISTER_LAYER
(
power
,
PowerLayer
);
...
...
paddle/gserver/layers/PrintLayer.cpp
浏览文件 @
ed808f5e
...
...
@@ -19,8 +19,8 @@ namespace paddle {
class
PrintLayer
:
public
Layer
{
public:
explicit
PrintLayer
(
const
LayerConfig
&
config
)
:
Layer
(
config
)
{}
void
forward
(
PassType
passType
);
void
backward
(
const
UpdateCallback
&
callback
)
{}
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
)
override
{}
};
void
PrintLayer
::
forward
(
PassType
passType
)
{
...
...
paddle/gserver/layers/PriorBox.cpp
浏览文件 @
ed808f5e
...
...
@@ -30,10 +30,11 @@ namespace paddle {
class
PriorBoxLayer
:
public
Layer
{
public:
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
backward
(
const
UpdateCallback
&
callback
)
{}
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
)
override
{}
protected:
int
numPriors_
;
...
...
paddle/gserver/layers/RecurrentLayer.cpp
浏览文件 @
ed808f5e
...
...
@@ -45,17 +45,18 @@ class RecurrentLayer : public Layer {
public:
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:
/**
...
...
paddle/gserver/layers/RecurrentLayerGroup.cpp
浏览文件 @
ed808f5e
...
...
@@ -33,15 +33,15 @@ public:
void
initSubNetwork
(
NeuralNetwork
*
rootNetwork
,
const
ModelConfig
&
config
,
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
());
const
std
::
vector
<
Argument
>
inArgs
;
std
::
vector
<
Argument
>
outArgs
;
network_
->
forward
(
inArgs
,
&
outArgs
,
passType
);
}
void
backward
(
const
UpdateCallback
&
callback
)
{
void
backward
(
const
UpdateCallback
&
callback
)
override
{
REGISTER_TIMER_INFO
(
"RecurrentGroupBwTime"
,
getName
().
c_str
());
network_
->
backward
(
nullptr
);
...
...
@@ -53,7 +53,8 @@ public:
/**
* @see Layer.accessSubNetwork
*/
void
accessSubNetwork
(
const
std
::
function
<
void
(
NeuralNetwork
&
)
>&
callback
)
{
void
accessSubNetwork
(
const
std
::
function
<
void
(
NeuralNetwork
&
)
>&
callback
)
override
{
callback
(
*
network_
);
}
...
...
paddle/gserver/layers/ResizeLayer.cpp
浏览文件 @
ed808f5e
...
...
@@ -20,18 +20,19 @@ namespace paddle {
/**
* @brief A layer for resizing a minibatch matrix h*w to h'*w'
* @note
* origin matrix height * wi
t
dth)
* origin matrix height * width)
* resize matrix: (height * width / size) * size
*/
class
ResizeLayer
:
public
Layer
{
public:
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
);
...
...
paddle/gserver/layers/SamplingIdLayer.cpp
浏览文件 @
ed808f5e
...
...
@@ -35,8 +35,8 @@ public:
explicit
SamplingIdLayer
(
const
LayerConfig
&
config
)
:
Layer
(
config
),
rand1_
(
0
,
1
)
{}
virtual
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
{
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
{
bool
ret
=
Layer
::
init
(
layerMap
,
parameterMap
);
CHECK_EQ
(
1UL
,
inputLayers_
.
size
());
if
(
useGpu_
)
{
...
...
@@ -48,7 +48,7 @@ public:
return
ret
;
}
void
forward
(
PassType
passType
)
{
void
forward
(
PassType
passType
)
override
{
Layer
::
forward
(
passType
);
if
(
useGpu_
)
{
for
(
size_t
i
=
0
;
i
<
inputLayers_
.
size
();
i
++
)
{
...
...
@@ -83,7 +83,7 @@ public:
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
);
...
...
paddle/gserver/layers/ScalingLayer.cpp
浏览文件 @
ed808f5e
...
...
@@ -37,10 +37,11 @@ public:
~
ScalingLayer
()
{}
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
void
forward
(
PassType
passType
);
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
);
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
override
;
};
REGISTER_LAYER
(
scaling
,
ScalingLayer
);
...
...
paddle/gserver/layers/SelectiveFullyConnectedLayer.h
浏览文件 @
ed808f5e
...
...
@@ -65,9 +65,10 @@ public:
:
Layer
(
config
),
selCols_
(
nullptr
)
{}
~
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
];
}
...
...
@@ -90,8 +91,8 @@ public:
void
fillSelectiveData
(
const
std
::
shared_ptr
<
std
::
vector
<
std
::
pair
<
int
*
,
size_t
>>>&
candidates
);
void
forward
(
PassType
passType
);
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
);
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
override
;
private:
/**
...
...
paddle/gserver/layers/SequenceConcatLayer.cpp
浏览文件 @
ed808f5e
...
...
@@ -35,10 +35,11 @@ public:
~
SequenceConcatLayer
()
{}
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
void
forward
(
PassType
passType
);
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
);
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
override
;
};
REGISTER_LAYER
(
seqconcat
,
SequenceConcatLayer
);
...
...
paddle/gserver/layers/SequenceLastInstanceLayer.cpp
浏览文件 @
ed808f5e
...
...
@@ -42,12 +42,11 @@ public:
explicit
SequenceLastInstanceLayer
(
const
LayerConfig
&
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
);
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
);
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
override
;
};
REGISTER_LAYER
(
seqlastins
,
SequenceLastInstanceLayer
);
...
...
paddle/gserver/layers/SequencePoolLayer.h
浏览文件 @
ed808f5e
...
...
@@ -46,12 +46,11 @@ protected:
public:
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
);
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
);
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
override
;
};
}
// namespace paddle
paddle/gserver/layers/SequenceReshapeLayer.cpp
浏览文件 @
ed808f5e
...
...
@@ -34,12 +34,11 @@ protected:
public:
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
);
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
);
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
override
;
};
REGISTER_LAYER
(
seqreshape
,
SequenceReshapeLayer
);
...
...
paddle/gserver/layers/SlopeInterceptLayer.cpp
浏览文件 @
ed808f5e
...
...
@@ -39,12 +39,11 @@ class SlopeInterceptLayer : public Layer {
public:
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
);
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
);
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
override
;
};
REGISTER_LAYER
(
slope_intercept
,
SlopeInterceptLayer
);
...
...
paddle/gserver/layers/SpatialPyramidPoolLayer.h
浏览文件 @
ed808f5e
...
...
@@ -43,9 +43,8 @@ protected:
public:
explicit
SpatialPyramidPoolLayer
(
const
LayerConfig
&
config
)
:
Layer
(
config
)
{}
~
SpatialPyramidPoolLayer
()
{}
virtual
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
ProjectionConfig
getConfig
(
size_t
sizeX_
,
size_t
sizeY_
,
...
...
@@ -54,7 +53,7 @@ public:
std
::
string
&
poolType_
);
size_t
getSize
();
v
irtual
void
forward
(
PassType
passType
)
;
v
irtual
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
;
v
oid
forward
(
PassType
passType
)
override
;
v
oid
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
override
;
};
}
// namespace paddle
paddle/gserver/layers/SubSequenceLayer.cpp
浏览文件 @
ed808f5e
...
...
@@ -35,12 +35,11 @@ protected:
public:
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
);
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
);
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
override
;
};
REGISTER_LAYER
(
subseq
,
SubSequenceLayer
);
...
...
paddle/gserver/layers/SumToOneNormLayer.cpp
浏览文件 @
ed808f5e
...
...
@@ -41,12 +41,11 @@ protected:
public:
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
);
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
);
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
override
;
};
REGISTER_LAYER
(
sum_to_one_norm
,
SumToOneNormLayer
);
...
...
paddle/gserver/layers/TensorLayer.h
浏览文件 @
ed808f5e
...
...
@@ -44,13 +44,12 @@ protected:
public:
explicit
TensorLayer
(
const
LayerConfig
&
config
)
:
Layer
(
config
)
{}
~
TensorLayer
()
{}
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
Weight
&
getWeight
(
int
idx
)
{
return
*
weights_
[
idx
];
}
void
forward
(
PassType
passType
);
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
);
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
override
;
};
}
// namespace paddle
paddle/gserver/layers/TransLayer.h
浏览文件 @
ed808f5e
...
...
@@ -32,9 +32,10 @@ class TransLayer : public Layer {
public:
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
backward
(
const
UpdateCallback
&
callback
=
nullptr
);
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
=
nullptr
)
override
;
};
}
// namespace paddle
paddle/gserver/layers/ValidationLayer.h
浏览文件 @
ed808f5e
...
...
@@ -26,7 +26,8 @@ class ValidationLayer : public Layer {
public:
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
];
}
...
...
@@ -37,13 +38,13 @@ public:
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
;
v
irtual
void
onPassEnd
()
=
0
;
v
oid
onPassEnd
()
override
=
0
;
};
/*
...
...
@@ -57,11 +58,12 @@ public:
cpuLabel_
(
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
{
PredictionResult
(
real
__out
,
int
__label
)
:
out
(
__out
),
label
(
__label
)
{}
...
...
@@ -86,11 +88,12 @@ public:
explicit
PnpairValidation
(
const
LayerConfig
&
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:
bool
passBegin_
;
...
...
paddle/gserver/layers/WarpCTCLayer.h
浏览文件 @
ed808f5e
...
...
@@ -30,9 +30,10 @@ public:
explicit
WarpCTCLayer
(
const
LayerConfig
&
config
)
:
Layer
(
config
)
{}
~
WarpCTCLayer
()
{}
virtual
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
);
virtual
void
forward
(
PassType
passType
);
virtual
void
backward
(
const
UpdateCallback
&
callback
);
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
override
;
void
forward
(
PassType
passType
)
override
;
void
backward
(
const
UpdateCallback
&
callback
)
override
;
protected:
/**
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录