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:
  • 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)

Create a SequenceLastLayer:

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

Apply the layer to a sequence:

Scope  (2)

Create a SequenceLastLayer that expects a length-3 sequence of 2x2 matrices:

Apply the layer to a sequence:

Create a SequenceLastLayer that expects a sequence of real numbers:

Apply the layer to an input:

The layer threads across a batch of inputs:

Applications  (1)

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:

Possible Issues  (1)

SequenceLastLayer cannot accept symbolic inputs:

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.

CMS

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

BibTeX

@misc{reference.wolfram_2023_sequencelastlayer, author="Wolfram Research", title="{SequenceLastLayer}", year="2017", howpublished="\url{https://reference.wolfram.com/language/ref/SequenceLastLayer.html}", note=[Accessed: 29-March-2024 ]}

BibLaTeX

@online{reference.wolfram_2023_sequencelastlayer, organization={Wolfram Research}, title={SequenceLastLayer}, year={2017}, url={https://reference.wolfram.com/language/ref/SequenceLastLayer.html}, note=[Accessed: 29-March-2024 ]}