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

Details and Options

  • AggregationLayer[f] operates on a tensor of size d1××dn to produce a vector of size d1, effectively applying the function f to the elements of each subtensor of size d2××dn.
  • Possible values for f are Mean, Min, Max and Total.
  • 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 of rank 2 or greater
    "Output"a vector
  • 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 using Total as the aggregation function:

Click for copyable input

Apply the layer to a matrix:

Click for copyable input

Scope  (2)

Possible Issues  (1)

See Also

TotalLayer  PoolingLayer  SummationLayer  NetChain  NetGraph  NetTrain

Introduced in 2017