FlattenLayer
represents a net layer that flattens any input tensor into a vector.
FlattenLayer[n]
represents a net layer that flattens its input to level n.
Details and Options
- FlattenLayer[] is equivalent to FlattenLayer[Infinity].
- FlattenLayer[…][input] explicitly computes the output from applying the layer to input.
- FlattenLayer[…][{input1,input2,…}] explicitly computes outputs for each of the inputi.
- In FlattenLayer[n], n can be one of the following:
-
n flatten the first n+1 dimensions together -n flatten the last n+1 dimensions together Infinity flatten all dimensions - FlattenLayer exposes the following ports for use in NetGraph etc.:
-
"Input" a tensor of arbitrary rank "Output" a tensor - FlattenLayer is typically used inside NetChain, NetGraph, etc. to transform higher-rank tensors into vectors.
- FlattenLayer normally infers the dimensions of its input from its context in NetChain etc. To specify the dimensions explicitly as {n1,n2,…}, use FlattenLayer["Input"->{n1,n2,…}].
Examples
open allclose allBasic Examples (2)
Create a FlattenLayer:
Create a FlattenLayer with specified input dimensions:
Scope (3)
Properties & Relations (4)
Possible Issues (2)
See Also
ReshapeLayer ReplicateLayer TransposeLayer PartLayer NetChain NetGraph Flatten
Related Guides
Introduced in 2016
(11.0)
| Updated in 2017 (11.1)