Skip to content

Commit 63fff00

Browse files
committed
Document reduce_first and reduce_last
1 parent fb52834 commit 63fff00

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

website/docs/api-layers.md

+46
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,52 @@ https://github.com/explosion/thinc/blob/master/thinc/layers/staticvectors.py
512512

513513
## Reduction operations {#reduction-ops}
514514

515+
### reduce_first {#reduce_first tag="function"}
516+
517+
<inline-list>
518+
519+
- **Input:** <ndarray>Ragged</ndarray>
520+
- **Output:** <ndarray shape="batch_size, nO">Floats2d</ndarray>
521+
522+
</inline-list>
523+
524+
Pooling layer that reduces the dimensions of the data by selecting the first
525+
item of each sequence. This is most useful after multi-head attention layers,
526+
which can learn to assign a good feature representation for the sequence to one
527+
of its elements.
528+
529+
| Argument | Type | Description |
530+
| ----------- | -------------------------------- | -------------------------- |
531+
| **RETURNS** | <tt>Model[Ragged, Floats2d]</tt> | The created pooling layer. |
532+
533+
```python
534+
https://github.com/explosion/thinc/blob/master/thinc/layers/reduce_first.py
535+
```
536+
537+
### reduce_last {#reduce_last tag="function"}
538+
539+
Pooling layer that reduces the dimensions of the data by selecting the last
540+
item of each sequence. This is typically used after multi-head attention or recurrent
541+
neural network layers such as LSTMs, which can learn to assign a good feature
542+
representation for the sequence to its final element.
543+
544+
<inline-list>
545+
546+
- **Input:** <ndarray>Ragged</ndarray>
547+
- **Output:** <ndarray shape="batch_size, nO">Floats2d</ndarray>
548+
549+
</inline-list>
550+
551+
| Argument | Type | Description |
552+
| ----------- | -------------------------------- | -------------------------- |
553+
| **RETURNS** | <tt>Model[Ragged, Floats2d]</tt> | The created pooling layer. |
554+
555+
```python
556+
https://github.com/explosion/thinc/blob/master/thinc/layers/reduce_last.py
557+
```
558+
559+
560+
515561
### reduce_max {#reduce_max tag="function"}
516562

517563
<inline-list>

0 commit comments

Comments
 (0)