AggregationLayer

AggregationLayer[f]

represents a layer that aggregates a tensor of arbitrary rank into a vector, using the function f.

AggregationLayer[f,n]

aggregates a tensor at level n.

AggregationLayer[f,n1;;n2]

aggregates a tensor at levels n1 through n2.

AggregationLayer[f,{n1,n2,}]

aggregates a tensor at levels n1,n2,.

Details and Options

  • AggregationLayer[f] operates on a tensor of dimensions {d1,,dn} to produce a vector of size d1, effectively mapping the function f over a list of flattened subtensors of size d2××dn.
  • AggregationLayer[f,{n1,,nk}] operates on a rank-m tensor of dimensions {d1,,dm} to produce a tensor of rank m-k, with dimensions Complement[{d1,,dm},{dn1,,dnk}].
  • Possible values for f are Mean, Min, Max and Total.
  • AggregationLayer[f] is equivalent to AggregationLayer[f,2;;All].
  • AggregationLayer[][input] explicitly computes the output from applying the layer.
  • AggregationLayer[][{input1,input2,}] explicitly computes outputs for each of the inputi.
  • AggregationLayer is typically used inside NetChain, NetGraph, etc. as the final stage in a chain of convolutions, poolings, etc. to convert a tensor with spatial dimensions into a fixed-size vector representation.
  • AggregationLayer exposes the following ports for use in NetGraph etc.:
  • "Input"a tensor
    "Output"a tensor
  • When it cannot be inferred from other layers in a larger net, the option "Input"{d1,,dn} can be used to fix the input of AggregationLayer to be a tensor of dimensions {d1,,dn}.

Examples

open allclose all

Basic Examples  (2)

Create an AggregationLayer using Max as the aggregation function:

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

Create an AggregationLayer that sums the elements of each column of a matrix:

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

Apply the layer to an input:

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

Scope  (4)

Properties & Relations  (1)

Possible Issues  (1)

See Also

TotalLayer  PoolingLayer  SummationLayer  NetChain  NetGraph  NetTrain

Introduced in 2017
(11.1)
| Updated in 2017
(11.2)