-
Notifications
You must be signed in to change notification settings - Fork 6k
stride pooling for max and average layer #2701
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
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1090,10 +1090,16 @@ def pooling_layer(input, | |
| name=None, | ||
| bias_attr=None, | ||
| agg_level=AggregateLevel.TO_NO_SEQUENCE, | ||
| stride=-1, | ||
| layer_attr=None): | ||
| """ | ||
| Pooling layer for sequence inputs, not used for Image. | ||
|
|
||
| If stride > 0, this layer slides a window whose size is determined by stride, | ||
| and return the pooling value of the window as the output. Thus, a long sequence | ||
| will be shorten. Note that for sequence with sub-sequence, the default value | ||
| of stride is -1. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the parameter stride specifies the intervals at which to apply the pooling operation.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
|
|
||
| The example usage is: | ||
|
|
||
| .. code-block:: python | ||
|
|
@@ -1112,6 +1118,8 @@ def pooling_layer(input, | |
| :param pooling_type: Type of pooling, MaxPooling(default), AvgPooling, | ||
| SumPooling, SquareRootNPooling. | ||
| :type pooling_type: BasePoolingType|None | ||
| :param stride: window size. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. stride --> the step size between successive pooling regions.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done, and update the comments in last_seq and first_seq at the same time. |
||
| :type stride: Int | ||
| :param bias_attr: Bias parameter attribute. False if no bias. | ||
| :type bias_attr: ParameterAttribute|None|False | ||
| :param layer_attr: The Extra Attributes for layer, such as dropout. | ||
|
|
@@ -1129,12 +1137,16 @@ def pooling_layer(input, | |
| extra_dict['output_max_index'] = pooling_type.output_max_index | ||
| extra_dict.update(ExtraLayerAttribute.to_kwargs(layer_attr)) | ||
|
|
||
| if agg_level == AggregateLevel.TO_SEQUENCE: | ||
| assert stride == -1 | ||
|
|
||
| Layer( | ||
| name=name, | ||
| type=pooling_type.name, | ||
| inputs=[Input(input.name)], | ||
| bias=ParamAttr.to_bias(bias_attr), | ||
| trans_type=agg_level, | ||
| stride=stride, | ||
| **extra_dict) | ||
|
|
||
| return LayerOutput( | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. And update the comments in SequencePoolLayer.h, AverageLayer.h and SequenceLastInstanceLayer.h at the same time.