@@ -512,6 +512,52 @@ https://github.com/explosion/thinc/blob/master/thinc/layers/staticvectors.py
512
512
513
513
## Reduction operations {#reduction-ops}
514
514
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
+
515
561
### reduce_max {#reduce_max tag="function"}
516
562
517
563
<inline-list >
0 commit comments