Skip to content

Commit dd61304

Browse files
committed
refine annotation
1 parent a5734f7 commit dd61304

File tree

5 files changed

+20
-16
lines changed

5 files changed

+20
-16
lines changed

paddle/gserver/layers/SequenceLastInstanceLayer.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,10 @@ namespace paddle {
2626
* If SequenceLevel = kNonseq:
2727
* Output: a sequence containing only the last instance of the input sequence
2828
* If stride_ > 0:
29-
* Output: a shorten sequence containing several last instances of the
30-
* input sequence with stride window.
29+
* Output: a shorten sequence. The operation of getting last instance of a
30+
* sequence is independently performed on every slice of the input
31+
* sequence, which is obtained by sliding a window with the window
32+
* size set to stride_.
3133
* If SequenceLevel = kSeq:
3234
* Check input sequence must has sub-sequence
3335
* Output: a sequence containing only the last instance of each sub-sequence

paddle/gserver/layers/SequencePoolLayer.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ namespace paddle {
2727
* output[i] = seqlastin/average/max_{for each instance in this
2828
* sequence}{input[i]}
2929
* If stride_ > 0:
30-
* Check input sequence must don't have sub-sequence
30+
* Check input sequence must not have sub-sequence
3131
* Output: a shorten sequence, pooling is performed upon a small local
32-
* area
32+
* area
3333
* If SequenceLevel = kSeq:
3434
* Check input sequence must has sub-sequence
3535
* Output: output size is the number of input sub-sequences
@@ -47,9 +47,9 @@ class SequencePoolLayer : public Layer {
4747
size_t newBatchSize_;
4848
ICpuGpuVectorPtr startPositions_;
4949
int stride_;
50-
// store the start position of each stride window
50+
// store the start position of each window
5151
IVectorPtr stridePositions_;
52-
// Whether it is reversed sequence
52+
// Whether the input sequence is reversed or not
5353
bool reversed_ = false;
5454

5555
public:

paddle/parameter/Argument.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,7 @@ void Argument::poolSequenceWithStride(const Argument& input,
589589
} else {
590590
int size = ceil((float)seqLength / stride);
591591
tgtBuf[seqId + 1] = tgtBuf[seqId] + size;
592-
for (int i = 0; i < size - 1; i++) {
592+
for (int i = 0; i < size - 1; ++i) {
593593
int cur = reversed ? starts[seqId + 1] - (size - 1 - i) * stride
594594
: stridePos.back() + stride;
595595
stridePos.emplace_back(cur);

paddle/parameter/Argument.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ struct Argument {
294294
/*
295295
After pooling with stride n (n is smaller than sequence length),
296296
a long sequence will be shorten.
297-
This function is not suitable for sequence with sub-sequence now.
297+
This function is invalid for sequence having sub-sequence.
298298
*/
299299
void poolSequenceWithStride(const Argument& input,
300300
size_t stride,

python/paddle/trainer_config_helpers/layers.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1347,9 +1347,10 @@ def last_seq(input,
13471347
"""
13481348
Get Last Timestamp Activation of a sequence.
13491349
1350-
If stride > 0, get last timestamp upon a stride window of sequence.
1351-
And a long sequence will be shorten. Note that for sequence with
1352-
sub-sequence, stride is default -1 now.
1350+
If stride > 0, this layer slides a window whose size is determined by stride,
1351+
and return the last value of the window as the output. Thus, a long sequence
1352+
will be shorten. Note that for sequence with sub-sequence, the default value
1353+
of stride is -1.
13531354
13541355
The simple usage is:
13551356
@@ -1362,7 +1363,7 @@ def last_seq(input,
13621363
:type name: basestring
13631364
:param input: Input layer name.
13641365
:type input: LayerOutput
1365-
:param stride: parameter of stride window.
1366+
:param stride: window size.
13661367
:type stride: Int
13671368
:param layer_attr: extra layer attributes.
13681369
:type layer_attr: ExtraLayerAttribute.
@@ -1402,9 +1403,10 @@ def first_seq(input,
14021403
"""
14031404
Get First Timestamp Activation of a sequence.
14041405
1405-
If stride > 0, get first timestamp upon a stride window of sequence,
1406-
and a long sequence will be shorten. Note that for sequence with
1407-
sub-sequence, stride is default -1 now.
1406+
If stride > 0, this layer slides a window whose size is determined by stride,
1407+
and return the first value of the window as the output. Thus, a long sequence
1408+
will be shorten. Note that for sequence with sub-sequence, the default value
1409+
of stride is -1.
14081410
14091411
The simple usage is:
14101412
@@ -1417,7 +1419,7 @@ def first_seq(input,
14171419
:type name: basestring
14181420
:param input: Input layer name.
14191421
:type input: LayerOutput
1420-
:param stride: parameter of stride window.
1422+
:param stride: window size.
14211423
:type stride: Int
14221424
:param layer_attr: extra layer attributes.
14231425
:type layer_attr: ExtraLayerAttribute.

0 commit comments

Comments
 (0)