Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add doc for AggregateLevel and ExpandLevel #2200

Merged
merged 2 commits into from
May 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions doc/api/v2/config/layer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,11 @@ trans_full_matrix_projection
Aggregate Layers
================

AggregateLevel
--------------
.. autoclass:: paddle.v2.layer.AggregateLevel
:noindex:

.. _api_v2.layer_pooling:

pooling
Expand Down Expand Up @@ -248,6 +253,11 @@ block_expand

.. _api_v2.layer_expand:

ExpandLevel
-----------
.. autoclass:: paddle.v2.layer.ExpandLevel
:noindex:

expand
------
.. autoclass:: paddle.v2.layer.expand
Expand Down
31 changes: 31 additions & 0 deletions python/paddle/trainer_config_helpers/layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,24 @@ def is_layer_type(type_name):


class AggregateLevel(object):
"""
PaddlePaddle supports three sequence types:

- :code:`SequenceType.NO_SEQUENCE` means the sample is not a sequence.
- :code:`SequenceType.SEQUENCE` means the sample is a sequence.
- :code:`SequenceType.SUB_SEQUENCE` means the sample is a nested sequence,
each timestep of which is also a sequence.

Accordingly, AggregateLevel supports two modes:

- :code:`AggregateLevel.EACH_TIMESTEP` means the aggregation acts on each
timestep of a sequence, both :code:`SUB_SEQUENCE` and :code:`SEQUENCE` will
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This actually aggregates over the whole sequence. Maybe change the name to TO_NON_SEUQNCE will be easier to understand.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it, I will change the name in next PR.

be aggregated to :code:`NO_SEQUENCE`.

- :code:`AggregateLevel.EACH_SEQUENCE` means the aggregation acts on each
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Accordingly, TO_SEQUENCE will be easier to understand.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it, I will change the name in next PR.

sequence of a nested sequence, :code:`SUB_SEQUENCE` will be aggregated to
:code:`SEQUENCE`.
"""
EACH_TIMESTEP = 'non-seq'
EACH_SEQUENCE = 'seq'

Expand Down Expand Up @@ -1454,6 +1472,19 @@ def first_seq(input,


class ExpandLevel(object):
"""
Please refer to AggregateLevel first.

ExpandLevel supports two modes:

- :code:`ExpandLevel.FROM_TIMESTEP` means the expandation acts on each
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

expandation => expansion

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it, I will fix it in next PR.

timestep of a sequence, :code:`NO_SEQUENCE` will be expanded to
:code:`SEQUENCE` or :code:`SUB_SEQUENCE`.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"acts on each timestep of a sequence" is not correct because the input for FROM_TIMESTEP is non-sequence. Perhaps we should consider change the name to FROM_NON_SEQUENCE.

Copy link
Contributor Author

@luotao1 luotao1 May 19, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it, I will change the name in next PR.


- :code:`ExpandLevel.FROM_SEQUENCE` means the expandation acts on each
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

expandation=> expansion

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it, I will fix it in next PR.

sequence of a nested sequence, :code:`SEQUENCE` will be expanded to
:code:`SUB_SEQUENCE`.
"""
FROM_TIMESTEP = AggregateLevel.EACH_TIMESTEP
FROM_SEQUENCE = AggregateLevel.EACH_SEQUENCE

Expand Down
4 changes: 2 additions & 2 deletions python/paddle/v2/layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,8 +404,8 @@ def to_proto_impl(self, **kwargs):
LayerV2 = Layer
data = DataLayerV2
data.__name__ = 'data'
AggregateLevel = conf_helps.layers.AggregateLevel
ExpandLevel = conf_helps.layers.ExpandLevel
AggregateLevel = conf_helps.AggregateLevel
ExpandLevel = conf_helps.ExpandLevel
memory = MemoryV2
memory.__name__ = 'memory'
memory.__doc__ = conf_helps.memory.__doc__
Expand Down