From fe3216508aca6e7068d21e699fa0bb0283acb21a Mon Sep 17 00:00:00 2001 From: luotao02 Date: Tue, 30 Aug 2016 03:20:38 +0000 Subject: [PATCH] catalog for trainer_config_helpers ISSUE=4584581 git-svn-id: https://svn.baidu.com/idl/trunk/paddle@1413 1ad973e4-5ce8-4261-8a94-b56d1f490c56 --- doc/index.md | 1 + doc/source/index.md | 4 - .../trainer_config_helpers/activations.rst | 92 +++++++++++++++- .../api/trainer_config_helpers/evaluators.rst | 103 +++++++++++++++++- .../evaluators_index.rst | 7 ++ doc/ui/api/trainer_config_helpers/index.md | 10 +- .../api/trainer_config_helpers/networks.rst | 97 ++++++++++++++++- .../trainer_config_helpers/networks_index.rst | 9 ++ .../api/trainer_config_helpers/optimizers.rst | 49 ++++++++- .../optimizers_index.rst | 7 ++ .../api/trainer_config_helpers/poolings.rst | 31 +++++- .../trainer_config_helpers/poolings_index.rst | 9 ++ .../trainer_config_helpers/activations.py | 20 ++-- .../trainer_config_helpers/evaluators.py | 50 ++++----- .../paddle/trainer_config_helpers/networks.py | 21 ---- .../paddle/trainer_config_helpers/poolings.py | 14 +-- 16 files changed, 435 insertions(+), 89 deletions(-) create mode 100644 doc/ui/api/trainer_config_helpers/evaluators_index.rst create mode 100644 doc/ui/api/trainer_config_helpers/networks_index.rst create mode 100644 doc/ui/api/trainer_config_helpers/optimizers_index.rst create mode 100644 doc/ui/api/trainer_config_helpers/poolings_index.rst diff --git a/doc/index.md b/doc/index.md index 5b5998fe054..1e49f05af85 100644 --- a/doc/index.md +++ b/doc/index.md @@ -9,5 +9,6 @@ User Guide * [User Interface](ui/index.md) * [Source Code Documents](source/index.md) * [Layer Documents](layer.md) +* [Trainer Config Helpers](ui/api/trainer_config_helpers/index.md) * [Example and Demo](demo/index.md) * [Cluster Train](cluster/index.md) diff --git a/doc/source/index.md b/doc/source/index.md index 669362a1c3a..55fcdeb3dfc 100644 --- a/doc/source/index.md +++ b/doc/source/index.md @@ -47,7 +47,3 @@ - [Lock](utils/lock.rst) - [Queue](utils/queue.rst) - [Thread](utils/thread.rst) - -## proto - -TBD diff --git a/doc/ui/api/trainer_config_helpers/activations.rst b/doc/ui/api/trainer_config_helpers/activations.rst index fea420f5926..ee036ecbac4 100644 --- a/doc/ui/api/trainer_config_helpers/activations.rst +++ b/doc/ui/api/trainer_config_helpers/activations.rst @@ -1,5 +1,91 @@ -Activations -=========== +BaseActivation +============== .. automodule:: paddle.trainer_config_helpers.activations - :members: + :members: BaseActivation + :noindex: + +AbsActivation +=============== + +.. automodule:: paddle.trainer_config_helpers.activations + :members: AbsActivation + :noindex: + +IdentityActivation +================== + +.. automodule:: paddle.trainer_config_helpers.activations + :members: IdentityActivation + :noindex: + +LinearActivation +================== + +.. automodule:: paddle.trainer_config_helpers.activations + :members: LinearActivation + :noindex: + +SquareActivation +================ + +.. automodule:: paddle.trainer_config_helpers.activations + :members: SquareActivation + :noindex: + +SigmoidActivation +================= + +.. automodule:: paddle.trainer_config_helpers.activations + :members: SigmoidActivation + :noindex: + +SoftmaxActivation +================= + +.. automodule:: paddle.trainer_config_helpers.activations + :members: SoftmaxActivation + :noindex: + +SequenceSoftmaxActivation +========================= + +.. automodule:: paddle.trainer_config_helpers.activations + :members: SequenceSoftmax + :noindex: + +ReluActivation +============== + +.. automodule:: paddle.trainer_config_helpers.activations + :members: ReluActivation + :noindex: + +BReluActivation +=============== + +.. automodule:: paddle.trainer_config_helpers.activations + :members: BReluActivation + :noindex: + +SoftReluActivation +================== + +.. automodule:: paddle.trainer_config_helpers.activations + :members: SoftReluActivation + :noindex: + +TanhActivation +============== + +.. automodule:: paddle.trainer_config_helpers.activations + :members: TanhActivation + :noindex: + +STanhActivation +=============== + +.. automodule:: paddle.trainer_config_helpers.activations + :members: STanhActivation + :noindex: + diff --git a/doc/ui/api/trainer_config_helpers/evaluators.rst b/doc/ui/api/trainer_config_helpers/evaluators.rst index fdcf3d303ea..0586c9907e4 100644 --- a/doc/ui/api/trainer_config_helpers/evaluators.rst +++ b/doc/ui/api/trainer_config_helpers/evaluators.rst @@ -1,5 +1,102 @@ -Evaluators -========== +Base +==== +.. automodule:: paddle.trainer_config_helpers.evaluators + :members: evaluator_base + :noindex: + +Classification +============== + +classification_error_evaluator +------------------------------ +.. automodule:: paddle.trainer_config_helpers.evaluators + :members: classification_error_evaluator + :noindex: + +auc_evaluator +------------- +.. automodule:: paddle.trainer_config_helpers.evaluators + :members: auc_evaluator + :noindex: + +ctc_error_evaluator +------------------- +.. automodule:: paddle.trainer_config_helpers.evaluators + :members: ctc_error_evaluator + :noindex: + +chunk_evaluator +--------------- +.. automodule:: paddle.trainer_config_helpers.evaluators + :members: chunk_evaluator + :noindex: + +precision_recall_evaluator +-------------------------- +.. automodule:: paddle.trainer_config_helpers.evaluators + :members: precision_recall_evaluator + :noindex: + +Rank +==== + +pnpair_evaluator +---------------- +.. automodule:: paddle.trainer_config_helpers.evaluators + :members: pnpair_evaluator + :noindex: + +Utils +===== +sum_evaluator +------------- .. automodule:: paddle.trainer_config_helpers.evaluators - :members: + :members: sum_evaluator + :noindex: + +column_sum_evaluator +-------------------- +.. automodule:: paddle.trainer_config_helpers.evaluators + :members: column_sum_evaluator + :noindex: + +Print +===== + +classification_error_printer_evaluator +-------------------------------------- +.. automodule:: paddle.trainer_config_helpers.evaluators + :members: classification_error_printer_evaluator + :noindex: + +gradient_printer_evaluator +-------------------------- +.. automodule:: paddle.trainer_config_helpers.evaluators + :members: gradient_printer_evaluator + :noindex: + +maxid_printer_evaluator +----------------------- +.. automodule:: paddle.trainer_config_helpers.evaluators + :members: maxid_printer_evaluator + :noindex: + +maxframe_printer_evaluator +--------------------------- +.. automodule:: paddle.trainer_config_helpers.evaluators + :members: maxframe_printer_evaluator + :noindex: + +seqtext_printer_evaluator +------------------------- +.. automodule:: paddle.trainer_config_helpers.evaluators + :members: seqtext_printer_evaluator + :noindex: + +value_printer_evaluator +----------------------- +.. automodule:: paddle.trainer_config_helpers.evaluators + :members: value_printer_evaluator + :noindex: + diff --git a/doc/ui/api/trainer_config_helpers/evaluators_index.rst b/doc/ui/api/trainer_config_helpers/evaluators_index.rst new file mode 100644 index 00000000000..298de3e1a32 --- /dev/null +++ b/doc/ui/api/trainer_config_helpers/evaluators_index.rst @@ -0,0 +1,7 @@ +Evaluators +========== + +.. toctree:: + :maxdepth: 3 + + evaluators.rst diff --git a/doc/ui/api/trainer_config_helpers/index.md b/doc/ui/api/trainer_config_helpers/index.md index a439e7a8cca..0255b4ba3d3 100644 --- a/doc/ui/api/trainer_config_helpers/index.md +++ b/doc/ui/api/trainer_config_helpers/index.md @@ -1,10 +1,10 @@ # Trainer Config Helpers -* [Optimizer](optimizers.rst) +* [Optimizer](optimizers_index.rst) * [Data Source](data_sources.rst) * [Layers](layers_index.rst) -* [Activations](activations.rst) -* [Poolings](poolings.rst) -* [Networks](networks.rst) -* [Evaluators](evaluators.rst) +* [Activations](activations_index.rst) +* [Poolings](poolings_index.rst) +* [Networks](networks_index.rst) +* [Evaluators](evaluators_index.rst) * [Parameter and Extra Layer Attribute](attrs.rst) diff --git a/doc/ui/api/trainer_config_helpers/networks.rst b/doc/ui/api/trainer_config_helpers/networks.rst index 255f154ed70..59370b71a69 100644 --- a/doc/ui/api/trainer_config_helpers/networks.rst +++ b/doc/ui/api/trainer_config_helpers/networks.rst @@ -1,5 +1,96 @@ -Networks -======== +NLP +=== +sequence_conv_pool +------------------ .. automodule:: paddle.trainer_config_helpers.networks - :members: + :members: sequence_conv_pool + :noindex: + +text_conv_pool +-------------- +.. automodule:: paddle.trainer_config_helpers.networks + :members: text_conv_pool + :noindex: + +Images +====== + +img_conv_bn_pool +---------------- +.. automodule:: paddle.trainer_config_helpers.networks + :members: img_conv_bn_pool + :noindex: + +img_conv_group +-------------- +.. automodule:: paddle.trainer_config_helpers.networks + :members: img_conv_group + :noindex: + +simple_img_conv_pool +-------------------- +.. automodule:: paddle.trainer_config_helpers.networks + :members: simple_img_conv_pool + :noindex: + +vgg_16_network +--------------- +.. automodule:: paddle.trainer_config_helpers.networks + :members: vgg_16_network + :noindex: + +Recurrent +========= + +lstmemory_unit +-------------- +.. automodule:: paddle.trainer_config_helpers.networks + :members: lstmemory_unit + :noindex: + +lstmemory_group +--------------- +.. automodule:: paddle.trainer_config_helpers.networks + :members: lstmemory_group + :noindex: + +gru_unit +--------- +.. automodule:: paddle.trainer_config_helpers.networks + :members: gru_unit + :noindex: + +simple_lstm +----------- +.. automodule:: paddle.trainer_config_helpers.networks + :members: simple_lstm + :noindex: + +bidirectional_lstm +------------------ +.. automodule:: paddle.trainer_config_helpers.networks + :members: bidirectional_lstm + :noindex: + +simple_attention +---------------- +.. automodule:: paddle.trainer_config_helpers.networks + :members: simple_attention + :noindex: + +Miscs +===== + +dropout_layer +-------------- +.. automodule:: paddle.trainer_config_helpers.networks + :members: dropout_layer + :noindex: + +outputs +------- +.. automodule:: paddle.trainer_config_helpers.networks + :members: outputs + :noindex: + diff --git a/doc/ui/api/trainer_config_helpers/networks_index.rst b/doc/ui/api/trainer_config_helpers/networks_index.rst new file mode 100644 index 00000000000..17bc4dfaa6c --- /dev/null +++ b/doc/ui/api/trainer_config_helpers/networks_index.rst @@ -0,0 +1,9 @@ +Networks +======== + +The networks module contains pieces of neural network that combine multiple layers. + +.. toctree:: + :maxdepth: 3 + + networks.rst diff --git a/doc/ui/api/trainer_config_helpers/optimizers.rst b/doc/ui/api/trainer_config_helpers/optimizers.rst index 3839d932ba0..31b9e057fbc 100644 --- a/doc/ui/api/trainer_config_helpers/optimizers.rst +++ b/doc/ui/api/trainer_config_helpers/optimizers.rst @@ -1,5 +1,48 @@ -Optimizers -========== +BaseSGDOptimizer +================ +.. automodule:: paddle.trainer_config_helpers.optimizers + :members: BaseSGDOptimizer + :noindex: + +AdamOptimizer +============= +.. automodule:: paddle.trainer_config_helpers.optimizers + :members: AdamOptimizer + :noindex: + +AdamxOptimizer +================ +.. automodule:: paddle.trainer_config_helpers.optimizers + :members: AdamxOptimizer + :noindex: + +AdaGradOptimizer +================ +.. automodule:: paddle.trainer_config_helpers.optimizers + :members: AdaGradOptimizer + :noindex: +DecayedAdaGradOptimizer +======================= .. automodule:: paddle.trainer_config_helpers.optimizers - :members: + :members: DecayedAdaGradOptimizer + :noindex: + +AdaDeltaOptimizer +================= +.. automodule:: paddle.trainer_config_helpers.optimizers + :members: AdaDeltaOptimizer + :noindex: + +RMSPropOptimizer +================ +.. automodule:: paddle.trainer_config_helpers.optimizers + :members: RMSPropOptimizer + :noindex: + +settings +======== +.. automodule:: paddle.trainer_config_helpers.optimizers + :members: settings + :noindex: + diff --git a/doc/ui/api/trainer_config_helpers/optimizers_index.rst b/doc/ui/api/trainer_config_helpers/optimizers_index.rst new file mode 100644 index 00000000000..f39f94f0cd6 --- /dev/null +++ b/doc/ui/api/trainer_config_helpers/optimizers_index.rst @@ -0,0 +1,7 @@ +Optimizers +========== + +.. toctree:: + :maxdepth: 3 + + optimizers.rst diff --git a/doc/ui/api/trainer_config_helpers/poolings.rst b/doc/ui/api/trainer_config_helpers/poolings.rst index 4d3c5dc486b..caadec63938 100644 --- a/doc/ui/api/trainer_config_helpers/poolings.rst +++ b/doc/ui/api/trainer_config_helpers/poolings.rst @@ -1,5 +1,30 @@ -Poolings -======== +BasePoolingType +=============== +.. automodule:: paddle.trainer_config_helpers.poolings + :members: BasePoolingType + :noindex: + +AvgPooling +========== +.. automodule:: paddle.trainer_config_helpers.poolings + :members: AvgPooling + :noindex: + +MaxPooling +========== +.. automodule:: paddle.trainer_config_helpers.poolings + :members: MaxPooling + :noindex: + +SumPooling +========== +.. automodule:: paddle.trainer_config_helpers.poolings + :members: SumPooling + :noindex: +SquareRootNPooling +================== .. automodule:: paddle.trainer_config_helpers.poolings - :members: + :members: SquareRootNPooling + :noindex: + diff --git a/doc/ui/api/trainer_config_helpers/poolings_index.rst b/doc/ui/api/trainer_config_helpers/poolings_index.rst new file mode 100644 index 00000000000..250d3fa69c0 --- /dev/null +++ b/doc/ui/api/trainer_config_helpers/poolings_index.rst @@ -0,0 +1,9 @@ +Poolings +======== + +These pooling types are used for sequence input, not for images. + +.. toctree:: + :maxdepth: 3 + + poolings.rst diff --git a/python/paddle/trainer_config_helpers/activations.py b/python/paddle/trainer_config_helpers/activations.py index b5895680a34..24defb06a6d 100644 --- a/python/paddle/trainer_config_helpers/activations.py +++ b/python/paddle/trainer_config_helpers/activations.py @@ -12,16 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -""" -Paddle Supported Activations. - -Each activation inherit BaseActivation, which has two attributes. - -- name: activation name in paddle config. -- support_hppl: True if supported by hppl. lstm layer can only use activations - supported by hppl (the name hppl will be revised later). -""" - __all__ = ["TanhActivation", "SigmoidActivation", "SoftmaxActivation", "IdentityActivation", "LinearActivation", 'SequenceSoftmaxActivation', @@ -31,7 +21,15 @@ __all__ = ["TanhActivation", "SigmoidActivation", class BaseActivation(object): """ - A mark for activation class. + A mark for activation class. + Each activation inherit BaseActivation, which has two parameters. + + :param name: activation name in paddle config. + :type name: basestring + :param support_hppl: True if supported by hppl. HPPL is a library used by paddle + internally. Currently, lstm layer can only use activations + supported by hppl. + :type support_hppl: bool """ def __init__(self, name, support_hppl): diff --git a/python/paddle/trainer_config_helpers/evaluators.py b/python/paddle/trainer_config_helpers/evaluators.py index 6d47eccca61..956bedadd75 100644 --- a/python/paddle/trainer_config_helpers/evaluators.py +++ b/python/paddle/trainer_config_helpers/evaluators.py @@ -12,35 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -""" -Evaluator will evaluate the network status while training/testing. - -User can use evaluator by classify/regression job. For example. - -.. code-block:: python - - classify(prediction, output, evaluator=classification_error_evaluator) - -And user could define evaluator separately as follow. - -.. code-block:: python - - classification_error_evaluator("ErrorRate", prediction, label) - -The evaluator often contains a name parameter. It will also be printed when -evaluating network. The printed information may look like the following. - -.. code-block:: text - - Batch=200 samples=20000 AvgCost=0.679655 CurrentCost=0.662179 Eval: - classification_error_evaluator=0.4486 - CurrentEval: ErrorRate=0.3964 - -""" from paddle.trainer.config_parser import * from default_decorators import * -__all__ = ["classification_error_evaluator", "auc_evaluator", +__all__ = ["evaluator_base","classification_error_evaluator", "auc_evaluator", "pnpair_evaluator", "precision_recall_evaluator", "ctc_error_evaluator", "chunk_evaluator", "sum_evaluator", "column_sum_evaluator", "value_printer_evaluator", @@ -97,6 +72,29 @@ def evaluator_base( num_results=1, delimited=True): """ + Evaluator will evaluate the network status while training/testing. + + User can use evaluator by classify/regression job. For example. + + .. code-block:: python + + classify(prediction, output, evaluator=classification_error_evaluator) + + And user could define evaluator separately as follow. + + .. code-block:: python + + classification_error_evaluator("ErrorRate", prediction, label) + + The evaluator often contains a name parameter. It will also be printed when + evaluating network. The printed information may look like the following. + + .. code-block:: text + + Batch=200 samples=20000 AvgCost=0.679655 CurrentCost=0.662179 Eval: + classification_error_evaluator=0.4486 + CurrentEval: ErrorRate=0.3964 + :param input: Input layers, a object of LayerOutput or a list of LayerOutput. :type input: list|LayerOutput diff --git a/python/paddle/trainer_config_helpers/networks.py b/python/paddle/trainer_config_helpers/networks.py index bb7a99d4420..65bd9102dc9 100644 --- a/python/paddle/trainer_config_helpers/networks.py +++ b/python/paddle/trainer_config_helpers/networks.py @@ -13,27 +13,6 @@ # limitations under the License. """ -The networks module contains pieces of neural network that combine multiple -layers. - -The pieces are: - -- NLP - - * Text Convolution component - -- Images - - * Conv_Pool - * Conv_BatchNorm_Pool - -- Recurrent - - * simple_lstm - -- Miscs - - * dropout_layer """ # from activations import * diff --git a/python/paddle/trainer_config_helpers/poolings.py b/python/paddle/trainer_config_helpers/poolings.py index cd6610d22fe..5e06d820058 100644 --- a/python/paddle/trainer_config_helpers/poolings.py +++ b/python/paddle/trainer_config_helpers/poolings.py @@ -13,12 +13,6 @@ # limitations under the License. """ -Pooling type that paddle supported. Note these pooling types are used for -sequence input, not for images. - -Each PoolingType contains. - -- name: pooling layer type name used by paddle. """ __all__ = [ @@ -32,7 +26,13 @@ __all__ = [ class BasePoolingType(object): """ - Base Pooling Type. + Base Pooling Type. + Note these pooling types are used for sequence input, not for images. + Each PoolingType contains one parameter: + + :param name: pooling layer type name used by paddle. + :type name: basestring + """ def __init__(self, name): self.name = name -- GitLab