SequenceLastLayer
✖
SequenceLastLayer
represents a net that takes a sequence of inputs and returns the last element of the sequence.
Details and Options

- SequenceLastLayer[] represents a net that takes a sequence of arrays and outputs a single array.
- SequenceLastLayer[…][input] explicitly computes the output from applying the layer.
- SequenceLastLayer[…][{input1,input2,…}] explicitly computes an output for each of the inputi.
- When given a NumericArray as input, the output will be a NumericArray.
- SequenceLastLayer is typically used inside NetChain, NetGraph, etc.
- The input and output ports of the net represented by SequenceLastLayer[] are:
-
"Input" a sequence of rank-n arrays "Output" a rank-n array - SequenceLastLayer["Input"->shape] allows the shape of the input to be specified. Possible forms for shape are:
-
n a sequence of n numbers "Varying" a vector whose length is variable {len,d1,d2,…} sequence of len arrays of dimensions d1×d2×… {"Varying",d1,d2,…} varying number of arrays of dimensions d1×d2×… - Options[SequenceLastLayer] gives the list of default options to construct the layer. Options[SequenceLastLayer[…]] gives the list of default options to evaluate the layer on some data.
- Information[SequenceLastLayer[…]] gives a report about the layer.
- Information[SequenceLastLayer[…],prop] gives the value of the property prop of SequenceLastLayer[…]. Possible properties are the same as for NetGraph.
Examples
open allclose allBasic Examples (2)Summary of the most common use cases
Create a SequenceLastLayer:

https://wolfram.com/xid/0elr455g7c2bici-3llf9j

Create a SequenceLastLayer that expects a sequence of vectors of size 3:

https://wolfram.com/xid/0elr455g7c2bici-87km7g

Apply the layer to a sequence:

https://wolfram.com/xid/0elr455g7c2bici-2pkt8a

Scope (2)Survey of the scope of standard use cases
Ports (2)
Create a SequenceLastLayer that expects a length-3 sequence of 2×2 matrices:

https://wolfram.com/xid/0elr455g7c2bici-ijrx8n

Apply the layer to a sequence:

https://wolfram.com/xid/0elr455g7c2bici-fa5hjk

Create a SequenceLastLayer that expects a sequence of real numbers:

https://wolfram.com/xid/0elr455g7c2bici-c20rly


https://wolfram.com/xid/0elr455g7c2bici-sp0sb

The layer threads across a batch of inputs:

https://wolfram.com/xid/0elr455g7c2bici-f7gpn6

Applications (1)Sample problems that can be solved with this function
SequenceLastLayer is commonly used to obtain a fixed-sized representation of a sequence, needed for tasks such as sequence classification, by taking the final output from a recurrent layer:

https://wolfram.com/xid/0elr455g7c2bici-vhdzh7

Possible Issues (1)Common pitfalls and unexpected behavior
SequenceLastLayer cannot accept symbolic inputs:

https://wolfram.com/xid/0elr455g7c2bici-ggaxyd


https://wolfram.com/xid/0elr455g7c2bici-56whoo


Wolfram Research (2017), SequenceLastLayer, Wolfram Language function, https://reference.wolfram.com/language/ref/SequenceLastLayer.html.
Text
Wolfram Research (2017), SequenceLastLayer, Wolfram Language function, https://reference.wolfram.com/language/ref/SequenceLastLayer.html.
Wolfram Research (2017), SequenceLastLayer, Wolfram Language function, https://reference.wolfram.com/language/ref/SequenceLastLayer.html.
CMS
Wolfram Language. 2017. "SequenceLastLayer." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/SequenceLastLayer.html.
Wolfram Language. 2017. "SequenceLastLayer." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/SequenceLastLayer.html.
APA
Wolfram Language. (2017). SequenceLastLayer. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/SequenceLastLayer.html
Wolfram Language. (2017). SequenceLastLayer. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/SequenceLastLayer.html
BibTeX
@misc{reference.wolfram_2025_sequencelastlayer, author="Wolfram Research", title="{SequenceLastLayer}", year="2017", howpublished="\url{https://reference.wolfram.com/language/ref/SequenceLastLayer.html}", note=[Accessed: 13-April-2025
]}
BibLaTeX
@online{reference.wolfram_2025_sequencelastlayer, organization={Wolfram Research}, title={SequenceLastLayer}, year={2017}, url={https://reference.wolfram.com/language/ref/SequenceLastLayer.html}, note=[Accessed: 13-April-2025
]}