提交 38764bf9 编写于 作者: X xuwei06

Add sum_cost to document

And rebase

Change-Id: I7ea234b3aa8fc70675af15d91db08242c43fb5ff
上级 ebad8e52
...@@ -465,6 +465,11 @@ SumOfSquaresCostLayer ...@@ -465,6 +465,11 @@ SumOfSquaresCostLayer
.. doxygenclass:: paddle::SumOfSquaresCostLayer .. doxygenclass:: paddle::SumOfSquaresCostLayer
:members: :members:
SumCostLayer
`````````````````````
.. doxygenclass:: paddle::SumCostLayer
:members:
CosSimLayer CosSimLayer
----------- -----------
.. doxygenclass:: paddle::CosSimLayer .. doxygenclass:: paddle::CosSimLayer
......
...@@ -395,6 +395,12 @@ hsigmoid ...@@ -395,6 +395,12 @@ hsigmoid
:members: hsigmoid :members: hsigmoid
:noindex: :noindex:
sum_cost
---------
.. automodule:: paddle.trainer_config_helpers.layers
:members: sum_cost
:noindex:
Check Layer Check Layer
============ ============
......
...@@ -562,6 +562,12 @@ void HuberTwoClass::backwardImpIn( ...@@ -562,6 +562,12 @@ void HuberTwoClass::backwardImpIn(
} }
} }
/**
* This cost layer compute the sum of its input as loss.
* \f[
* o(i) = \sum_{j=1}^D y_{ij}
* \f]
*/
class SumCostLayer : public Layer { class SumCostLayer : public Layer {
public: public:
explicit SumCostLayer(const LayerConfig& config) : Layer(config) {} explicit SumCostLayer(const LayerConfig& config) : Layer(config) {}
......
...@@ -129,7 +129,7 @@ protected: ...@@ -129,7 +129,7 @@ protected:
* This cost layer compute Euclidean (L2) loss for real-valued regression * This cost layer compute Euclidean (L2) loss for real-valued regression
* tasks. * tasks.
* \f[ * \f[
* L = \frac{1}{2N} \sum_{i=1}^N {|| \hat{y}_i - y_i||_2^2} * L = \sum_{i=1}^N {|| \hat{y}_i - y_i||_2^2}
* \f] * \f]
*/ */
class SumOfSquaresCostLayer : public CostLayer { class SumOfSquaresCostLayer : public CostLayer {
......
...@@ -23,6 +23,17 @@ layers { ...@@ -23,6 +23,17 @@ layers {
size: 10 size: 10
active_type: "" active_type: ""
} }
layers {
name: "__fc_layer_0__"
type: "fc"
size: 4
active_type: "tanh"
inputs {
input_layer_name: "input"
input_parameter_name: "___fc_layer_0__.w0"
}
bias_parameter_name: "___fc_layer_0__.wbias"
}
layers { layers {
name: "__ctc_layer_0__" name: "__ctc_layer_0__"
type: "ctc" type: "ctc"
...@@ -36,17 +47,6 @@ layers { ...@@ -36,17 +47,6 @@ layers {
} }
norm_by_times: false norm_by_times: false
} }
layers {
name: "__fc_layer_0__"
type: "fc"
size: 4
active_type: "tanh"
inputs {
input_layer_name: "input"
input_parameter_name: "___fc_layer_0__.w0"
}
bias_parameter_name: "___fc_layer_0__.wbias"
}
layers { layers {
name: "crf_label" name: "crf_label"
type: "data" type: "data"
...@@ -191,6 +191,16 @@ layers { ...@@ -191,6 +191,16 @@ layers {
} }
coeff: 1.0 coeff: 1.0
} }
layers {
name: "__sum_cost_0__"
type: "sum_cost"
size: 1
active_type: ""
inputs {
input_layer_name: "__fc_layer_0__"
}
coeff: 1.0
}
parameters { parameters {
name: "___fc_layer_0__.w0" name: "___fc_layer_0__.w0"
size: 800 size: 800
...@@ -241,14 +251,15 @@ output_layer_names: "__cross_entropy_0__" ...@@ -241,14 +251,15 @@ output_layer_names: "__cross_entropy_0__"
output_layer_names: "__cross_entropy_with_selfnorm_0__" output_layer_names: "__cross_entropy_with_selfnorm_0__"
output_layer_names: "__huber_cost_0__" output_layer_names: "__huber_cost_0__"
output_layer_names: "__multi_binary_label_cross_entropy_0__" output_layer_names: "__multi_binary_label_cross_entropy_0__"
output_layer_names: "__sum_cost_0__"
sub_models { sub_models {
name: "root" name: "root"
layer_names: "input" layer_names: "input"
layer_names: "labels" layer_names: "labels"
layer_names: "probs" layer_names: "probs"
layer_names: "xe-label" layer_names: "xe-label"
layer_names: "__ctc_layer_0__"
layer_names: "__fc_layer_0__" layer_names: "__fc_layer_0__"
layer_names: "__ctc_layer_0__"
layer_names: "crf_label" layer_names: "crf_label"
layer_names: "__crf_layer_0__" layer_names: "__crf_layer_0__"
layer_names: "left" layer_names: "left"
...@@ -264,6 +275,7 @@ sub_models { ...@@ -264,6 +275,7 @@ sub_models {
layer_names: "huber_label" layer_names: "huber_label"
layer_names: "__huber_cost_0__" layer_names: "__huber_cost_0__"
layer_names: "__multi_binary_label_cross_entropy_0__" layer_names: "__multi_binary_label_cross_entropy_0__"
layer_names: "__sum_cost_0__"
input_layer_names: "input" input_layer_names: "input"
input_layer_names: "labels" input_layer_names: "labels"
input_layer_names: "crf_label" input_layer_names: "crf_label"
...@@ -284,6 +296,7 @@ sub_models { ...@@ -284,6 +296,7 @@ sub_models {
output_layer_names: "__cross_entropy_with_selfnorm_0__" output_layer_names: "__cross_entropy_with_selfnorm_0__"
output_layer_names: "__huber_cost_0__" output_layer_names: "__huber_cost_0__"
output_layer_names: "__multi_binary_label_cross_entropy_0__" output_layer_names: "__multi_binary_label_cross_entropy_0__"
output_layer_names: "__sum_cost_0__"
is_recurrent_layer_group: false is_recurrent_layer_group: false
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册