From 38de3a6cab8d6a05d1a6e1c07ae415a229953de6 Mon Sep 17 00:00:00 2001 From: Yu Yang Date: Sat, 4 Mar 2017 16:08:54 +0800 Subject: [PATCH] Complete docs of attr --- doc/api/v2/model_configs.rst | 8 ++++++++ python/paddle/v2/attr.py | 10 +++++++--- python/paddle/v2/config_base.py | 6 ++++++ 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/doc/api/v2/model_configs.rst b/doc/api/v2/model_configs.rst index a9f33b33ef..4ca28315d5 100644 --- a/doc/api/v2/model_configs.rst +++ b/doc/api/v2/model_configs.rst @@ -4,3 +4,11 @@ Layers .. automodule:: paddle.v2.layer :members: + + +========== +Attributes +========== + +.. automodule:: paddle.v2.attr + :members: diff --git a/python/paddle/v2/attr.py b/python/paddle/v2/attr.py index 40c64f621b..32f78614e7 100644 --- a/python/paddle/v2/attr.py +++ b/python/paddle/v2/attr.py @@ -12,12 +12,16 @@ # See the License for the specific language governing permissions and # limitations under the License. -from paddle.trainer_config_helpers.attrs import * +import paddle.trainer_config_helpers.attrs __all__ = [ "Param", "Extra", ] -Param = ParameterAttribute -Extra = ExtraLayerAttribute +Param = paddle.trainer_config_helpers.attrs.ParameterAttribute +Extra = paddle.trainer_config_helpers.attrs.ExtraLayerAttribute + +for each in paddle.trainer_config_helpers.attrs.__all__: + globals()[each] = getattr(paddle.trainer_config_helpers.attrs, each) + __all__.append(each) diff --git a/python/paddle/v2/config_base.py b/python/paddle/v2/config_base.py index 64de568fcc..1ec1d7bbdf 100644 --- a/python/paddle/v2/config_base.py +++ b/python/paddle/v2/config_base.py @@ -42,6 +42,12 @@ class LayerType(type): # replace LayerOutput to paddle.v2.config_base.Layer doc = doc.replace("LayerOutput", "paddle.v2.config_base.Layer") + doc = doc.replace('ParameterAttribute', + 'paddle.v2.attr.ParameterAttribute') + + doc = re.sub(r'ExtraLayerAttribute[^\s]?', + 'paddle.v2.attr.ExtraAttribute', doc) + # xxx_layer to xxx doc = re.sub(r"(?P[a-z]+)_layer", r"\g", doc) -- GitLab