NetMapThreadOperator

NetMapThreadOperator[mapnet]

represents a net in which mapnet is mapped over one or more inputs to give one or more outputs.

NetMapThreadOperator[mapnet,n]

represents a net in which mapnet is mapped over its inputs at depth n.

NetMapThreadOperator[mapnet,"input1"n1,"input2"n2,]

represents a net in which mapnet is mapped over the input named inputi at depth ni, and all other inputs are replicated.

Details

  • NetMapThreadOperator[mapnet] represents a net that takes the same number of arrays as mapnet and produces the same number of arrays as mapnet, but repeatedly applies mapnet to corresponding elements of the inputs.
  • NetMapThreadOperator[mapnet] effectively maps mapnet simultaneously over the first level of each of its inputs. These inputs must have the same length.
  • NetMapThreadOperator[mapnet] is equivalent to NetMapThreadOperator[mapnet,1].
  • NetMapThreadOperator[mapnet,n] effectively applies mapnet at level n to its inputs, and hence expects n additional dimensions over the inputs and outputs of mapnet.
  • Therefore, if mapnet takes an input of rank i and produces an output of rank o, NetMapThreadOperator[mapnet,n] takes an input of rank n+i and produces an output of rank n+o.
  • NetMapThreadOperator[mapnet,{"input1"n1,,"inputk"nk}] effectively maps mapnet at level n=Max[{n1,,nk}] by replicating those inputs with ni<n as appropriate.
  • Specifying "inputi"->0 is equivalent to omitting the input from the level specification and means that the unmodified input is supplied to each mapped application of subnet unchanged.
  • NetMapThreadOperator[net] can be seen as allowing a form of weight sharing between multiple copies of net, one for each element that is being mapped.
  • NetExtract can be used to extract mapnet from a NetMapThreadOperator[mapnet] object.
  • NetMapThreadOperator[net,"inputi"shape] allows the shape of the individual inputs 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 remaining dimensions are d2×d3×
  • When given a NumericArray as input, the output will be a NumericArray.

Examples

Basic Examples  (3)

Map a MeanAbsoluteLossLayer over corresponding inputs and targets to produce a vector of losses:

In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]=
In[3]:=
Click for copyable input
Out[3]=

Map a MeanAbsoluteLossLayer at level 2 of input and target matrices to produce a result matrix:

In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]=
In[3]:=
Click for copyable input
Out[3]=

Map a MeanAbsoluteLossLayer at level 1 of the input vector only, replicating the target vector:

In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]=
In[3]:=
Click for copyable input
Out[3]=
Introduced in 2019
(12.0)