diff --git a/doc/index.md b/doc/index.md index 5b5998fe054837c41af8ff98bca8cff75cb55fad..1e49f05af85181bff41d34c53f0100aa90b91a6d 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 669362a1c3ad5ac10d9e74ffdafab9f21fd660fd..55fcdeb3dfcedd8589bf7986682708a957c05746 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 fea420f5926560d784fd2c77a25b1e41c95fac27..ee036ecbac47f7e00f4c6eb5d057c530d0fa2a89 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 fdcf3d303ea49197b78fc28c64a9d732b9304241..0586c9907e472dd98c5f7e9098251f3bc6b88bab 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 0000000000000000000000000000000000000000..298de3e1a32d36b9102f5ad64cc1b968f418041b --- /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 a439e7a8ccabd72a7818999adcf0e7977dcd06b5..0255b4ba3d39d1dca8862fb138271f260dfdbdbf 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 255f154ed70733e5bfc200af4de32393e3006aea..59370b71a698a302930ad814328ae573c802da6d 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 0000000000000000000000000000000000000000..17bc4dfaa6c4ed3cd5daf0476d0d4c15a2067a22 --- /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 3839d932ba0a19d901ca5abd9369b03d39855730..31b9e057fbc60d1e7b9c9f3f3982787145046432 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 0000000000000000000000000000000000000000..f39f94f0cd6e1a6c3c25eeceb7820a7fbc070570 --- /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 4d3c5dc486b5f8fdc2ebfa007a5e6582ea47c5f2..caadec639383aad24ed477d8bdaeaa31c0026bb5 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 0000000000000000000000000000000000000000..250d3fa69c0dcedfd689b685fe7b47ec71d02fee --- /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 b5895680a3419e3763de0bf45420f783d3021664..24defb06a6d66692e266c3102a5b3334d7493d38 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 6d47eccca6137c573e3d6ffa4947fd313324b4d3..956bedadd75e5f389c25c37c1a466a0c3cb97430 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 bb7a99d4420018a23c5092354583f65868bac4bc..65bd9102dc99e503ccfe492590921a31a9e57027 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 cd6610d22fecca77e9924da64d81b2dc270380e4..5e06d82005841c9dad899399695a48d8c42280b0 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