NetMapOperator

NetMapOperator[net]

represents a net in which net is mapped over a sequence of inputs to give a sequence of outputs.

Details and Options

  • NetMapOperator[net] represents a net that takes a sequence of arrays and outputs a sequence of the same length.
  • NetMapOperator[net] accepts a single input sequence {x1,x2,,xn} and computes {net[x1],net[x2],,net[xn]}.
  • In NetMapOperator[net], net should take exactly one input and produce exactly one output.
  • NetExtract can be used to extract net from a NetMapOperator[net] object.
  • The input and output ports of the net represented by NetMapOperator are:
  • "Input"a sequence of arrays
    "Output"a sequence of arrays
  • NetMapOperator[net] can be seen as allowing a form of weight sharing between multiple copies of net, one for each sequence element that is being mapped.
  • NetMapOperator[net,"Input"->shape] allows the shape of the input to be specified. Possible forms for shape are:
  • da vector of size d
    {d1,d2}a matrix of size d1×d2
    {d1,d2,}an array of shape d1×d2×
    {"Varying",d2,d3,}an array whose first dimension is variable and whose remaining dimensions are d2×d3×
  • The following training parameter can be included:
  • LearningRateMultipliersAutomaticlearning rate multipliers for trainable arrays in the net
  • NetExtract allows access to the forward and reverse nets via "Net".
  • Options[NetMapOperator] gives the list of default options to construct the operator. Options[NetMapOperator[]] gives the list of default options to evaluate the operator on some data.
  • Information[NetMapOperator[]] gives a report about the operator.
  • Information[NetMapOperator[],prop] gives the value of the property prop of NetMapOperator[]. Possible properties are the same as for NetGraph.

Examples

open allclose all

Basic Examples  (2)

Create a NetMapOperator that maps a LinearLayer over a sequence:

Create a NetMapOperator that maps a SummationLayer over a sequence:

Apply the layer to a sequence of vectors:

The layer threads across a batch of sequences of different lengths:

Scope  (3)

Create a net that maps a LinearLayer over a sequence of vectors that have been one-hot encoded from the characters of a string:

Apply the net to some inputs:

The initialized LinearLayer can be obtained using NetExtract:

Create a net that maps a single pooling layer over a pair of images. First create a pooling layer that operates on images:

Create a net that maps the pooling layer over sequences of images:

Use NetMapOperator to apply a one-dimensional pooling to each row of an image:

Applications  (1)

Sorting lists of numbers. Generate a test and training set consisting of lists of integers between 1 and 6:

Display three random samples drawn from the training set:

Define a NetGraph with an AttentionLayer:

Train the net:

Use the net to sort a list of integers:

Properties & Relations  (1)

NetMapOperator can be used to implement NetPairEmbeddingOperator. Create an initialized LinearLayer:

Create NetPairEmbeddingOperator using the linear layer as its embedding net, and evaluate it on an input:

Define a NetGraph with a NetMapOperator that is equivalent to the previous NetPairEmbeddingOperator, and evaluate it on the same input:

Wolfram Research (2017), NetMapOperator, Wolfram Language function, https://reference.wolfram.com/language/ref/NetMapOperator.html (updated 2020).

Text

Wolfram Research (2017), NetMapOperator, Wolfram Language function, https://reference.wolfram.com/language/ref/NetMapOperator.html (updated 2020).

CMS

Wolfram Language. 2017. "NetMapOperator." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2020. https://reference.wolfram.com/language/ref/NetMapOperator.html.

APA

Wolfram Language. (2017). NetMapOperator. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/NetMapOperator.html

BibTeX

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

BibLaTeX

@online{reference.wolfram_2023_netmapoperator, organization={Wolfram Research}, title={NetMapOperator}, year={2020}, url={https://reference.wolfram.com/language/ref/NetMapOperator.html}, note=[Accessed: 19-March-2024 ]}