FlattenLayer

FlattenLayer[]

represents a net layer that flattens any input array into a vector.

FlattenLayer[n]

represents a net layer that flattens its input to level n.

FlattenLayer[{{s11,s12,},{s21,s22,},}]

represents a net layer that flattens its input by combining all levels sij to make each level i in the result.

Details and Options

Examples

open allclose all

Basic Examples  (2)

Create a FlattenLayer:

Create a FlattenLayer with specified input dimensions:

Apply the layer to a matrix:

Scope  (4)

Create a FlattenLayer that flattens the first two dimensions of the input, preserving the other dimensions:

Apply the layer to an input:

Create a FlattenLayer that flattens the first three dimensions of its input together, and apply it to a 2×3×4×5 array:

Create and apply a FlattenLayer that flattens the last three dimensions together:

Create and apply a layer that flattens all the dimensions together:

Create a FlattenLayer that flattens levels 2 and 3 into the first level of the resulting array:

Create a FlattenLayer with specified input dimensions:

Thread the layer across a batch of inputs:

Properties & Relations  (3)

FlattenLayer[] behaves like Flatten:

FlattenLayer[n] computes:

Create a rank-3 array:

Flatten the first two dimensions:

Flatten the last two dimensions:

FlattenLayer[n] is equivalent to a ReshapeLayer[dims], where the dims depend on n and the dimensions of the input to FlattenLayer. Create a rank-3 array:

Apply a particular FlattenLayer:

Apply an equivalent ReshapeLayer:

Possible Issues  (1)

FlattenLayer cannot accept symbolic inputs:

Wolfram Research (2016), FlattenLayer, Wolfram Language function, https://reference.wolfram.com/language/ref/FlattenLayer.html (updated 2021).

Text

Wolfram Research (2016), FlattenLayer, Wolfram Language function, https://reference.wolfram.com/language/ref/FlattenLayer.html (updated 2021).

CMS

Wolfram Language. 2016. "FlattenLayer." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2021. https://reference.wolfram.com/language/ref/FlattenLayer.html.

APA

Wolfram Language. (2016). FlattenLayer. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/FlattenLayer.html

BibTeX

@misc{reference.wolfram_2024_flattenlayer, author="Wolfram Research", title="{FlattenLayer}", year="2021", howpublished="\url{https://reference.wolfram.com/language/ref/FlattenLayer.html}", note=[Accessed: 21-November-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_flattenlayer, organization={Wolfram Research}, title={FlattenLayer}, year={2021}, url={https://reference.wolfram.com/language/ref/FlattenLayer.html}, note=[Accessed: 21-November-2024 ]}