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


aggregates a tensor at level n.


aggregates a tensor at levels n1 through 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, Total and Times.
  • 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 can operate on tensors that contain "Varying" dimensions.
  • 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}.


open allclose all

Basic Examples  (2)

Create an AggregationLayer using Max as the aggregation function:

Click for copyable input

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

Click for copyable input

Apply the layer to an input:

Click for copyable input

Scope  (5)

Properties & Relations  (1)

Possible Issues  (1)

See Also

TotalLayer  PoolingLayer  SummationLayer  NetChain  NetGraph  NetTrain


Introduced in 2017
| Updated in 2018