AggregationLayer
represents a layer that aggregates an array of arbitrary rank into a vector, using the function f.
AggregationLayer[f,n]
aggregates an array at level n.
AggregationLayer[f,n1;;n2]
aggregates an array at levels n1 through n2.
AggregationLayer[f,{n1,n2,…}]
aggregates an array at levels n1,n2,….
Details and Options
- AggregationLayer is typically used inside NetChain, NetGraph, etc. as the final stage in a chain of convolutions, poolings, etc. to convert an array with spatial dimensions into a fixed-size vector representation.
- AggregationLayer[f] operates on an array of dimensions {d1,…,dn} to produce a vector of size d1, effectively mapping the function f over a list of flattened subarrays of size d2×…×dn.
- AggregationLayer[f,{n1,…,nk}] operates on a rank-m array of dimensions {d1,…,dm} to produce an array of rank m-k, with dimensions Complement[{d1,…,dm},{dn1,…,dnk}].
- Possible values for f are Mean, Min, Max, Total, Times, Median, Variance, StandardDeviation, MeanDeviation and InterquartileRange.
- AggregationLayer[f] is equivalent to AggregationLayer[f,2;;All].
- AggregationLayer exposes the following ports for use in NetGraph etc.:
-
"Input" an array "Output" an array - 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 an array of dimensions {d1,…,dn}.
- AggregationLayer[…][input] explicitly computes the output from applying the layer.
- AggregationLayer[…][{input1,input2,…}] explicitly computes outputs for each of the inputi.
- When given a NumericArray as input, the output will be a NumericArray.
- Options[AggregationLayer] gives the list of default options to construct the layer. Options[AggregationLayer[…]] gives the list of default options to evaluate the layer on some data.
- Information[AggregationLayer[…]] gives a report about the layer.
- Information[AggregationLayer[…],prop] gives the value of the property prop of AggregationLayer[…]. Possible properties are the same as for NetGraph.
Examples
open allclose allBasic Examples (2)
Create an AggregationLayer using Max as the aggregation function:
Create an AggregationLayer that sums the elements of each row of a matrix:
Scope (5)
Create an AggregationLayer that finds the maximum value of an array:
Create an AggregationLayer that aggregates over the first, third and fourth dimensions of an input array:
Create an AggregationLayer with the input size specified:
Thread the layer across a batch of inputs:
Apply an AggregationLayer to aggregate over all the pixels in an image, returning the mean values for each color channel:
Apply an AggregationLayer to aggregate across color channels, turning a color image into a grayscale one:
Apply an AggregationLayer to aggregate over a varying dimension:
Properties & Relations (1)
AggregationLayer[f,{n1,…,nk}] is equivalent to:
Possible Issues (1)
AggregationLayer cannot accept symbolic inputs:
Text
Wolfram Research (2017), AggregationLayer, Wolfram Language function, https://reference.wolfram.com/language/ref/AggregationLayer.html (updated 2020).
CMS
Wolfram Language. 2017. "AggregationLayer." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2020. https://reference.wolfram.com/language/ref/AggregationLayer.html.
APA
Wolfram Language. (2017). AggregationLayer. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/AggregationLayer.html