WOLFRAM

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:
  • na 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 all

Basic Examples  (2)Summary of the most common use cases

Create a SequenceLastLayer:

Out[1]=1

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

Out[1]=1

Apply the layer to a sequence:

Out[2]=2

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:

Out[1]=1

Apply the layer to a sequence:

Out[2]=2

Create a SequenceLastLayer that expects a sequence of real numbers:

Out[1]=1

Apply the layer to an input:

Out[2]=2

The layer threads across a batch of inputs:

Out[3]=3

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:

Out[1]=1

Possible Issues  (1)Common pitfalls and unexpected behavior

SequenceLastLayer cannot accept symbolic inputs:

Out[1]=1
Out[2]=2
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.

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 ]}

@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 ]}

@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 ]}