represents a net layer that transposes the first two levels of its input.
TransposeLayer[mn]
represents a net layer that transposes levels m and n of its input.
TransposeLayer[{m1n1,m2n2,…}]
represents a net layer that sequentially transposes levels mi and ni of its input.
TransposeLayer[{n1,n2,…}]
represents a net layer such that the k
level of the input is the nk
level in the output.
TransposeLayer
represents a net layer that transposes the first two levels of its input.
TransposeLayer[mn]
represents a net layer that transposes levels m and n of its input.
TransposeLayer[{m1n1,m2n2,…}]
represents a net layer that sequentially transposes levels mi and ni of its input.
TransposeLayer[{n1,n2,…}]
represents a net layer such that the k
level of the input is the nk
level in the output.
Details and Options
- TransposeLayer[] is equivalent to TransposeLayer[12].
- When applied to an input of dimensions {d1,…,dm,…,dn,…}, TransposeLayer[mn] will produce an output of dimensions {d1,…,dn,…,dm,…}.
- TransposeLayer[…][input] explicitly computes the output from applying the layer to input.
- TransposeLayer[…][{input1,input2,…}] explicitly computes an output for each of the inputi.
- When given a NumericArray as input, the output will be a NumericArray.
- TransposeLayer exposes the following ports for use in NetGraph etc.:
-
"Input" an array "Output" an array - TransposeLayer is typically used inside NetChain, NetGraph, etc.
- TransposeLayer normally infers the dimensions of its input from its context in NetChain etc. To specify the dimensions explicitly as {n1,n2,…}, use TransposeLayer["Input"{n1,n2,…}].
- Options[TransposeLayer] gives the list of default options to construct the layer. Options[TransposeLayer[…]] gives the list of default options to evaluate the layer on some data.
- Information[TransposeLayer[…]] gives a report about the layer.
- Information[TransposeLayer[…],prop] gives the value of the property prop of TransposeLayer[…]. Possible properties are the same as for NetGraph.
Examples
open all close allBasic Examples (2)
Create a TransposeLayer:
trans = TransposeLayer[]Create a TransposeLayer that takes a matrix as input:
trans = TransposeLayer["Input" -> {3, 2}]trans[{{1, 2}, {3, 4}, {5, 6}}]//MatrixFormScope (6)
Arguments (1)
Create a TransposeLayer that transposes the first and third dimensions of an input array:
trans = TransposeLayer[1 3]Apply the layer to a 1×2×3 array to produce a 3×2×1 array:
trans[RandomReal[1, {1, 2, 3}]]Ports (5)
Create a TransposeLayer that takes a matrix as input:
trans = TransposeLayer[1 2, "Input" -> {1, 2}]The layer threads across a batch of examples:
in = {{1, 2}};
trans[{in, in, in, in}]Create a TransposeLayer that swap axis 1 with axis 3 and axis 2 with axis 4:
trans = TransposeLayer[{1 3, 2 4}, "Input" -> {3, 4, 5, 6}]Apply the layer to a 3×4×5×6 array to produce a 5×6×3×4 array:
trans@RandomReal[1, {3, 4, 5, 6}];Dimensions[%]Create a TransposeLayer that swaps axes 1 and 3 and subsequently swaps axes 1 and 4:
trans = TransposeLayer[{1 3, 1 4}, "Input" -> {3, 4, 5, 6}]Apply the layer to a 3×4×5×6 array to produce a 6×4×3×5 array:
trans@RandomReal[1, {3, 4, 5, 6}];Dimensions[%]Create a TransposeLayer that swaps axes with given permutations:
TransposeLayer[{1, 4, 2, 3}, "Input" -> {1, 2, 3, 4}]Create a TransposeLayer with partially specified input size that swaps axes with given permutations:
TransposeLayer[{1, 3, 2, 4}, "Input" -> {1, Automatic, 3, Automatic}]Possible Issues (1)
TransposeLayer cannot accept symbolic inputs:
trans = TransposeLayer[];
trans[{{1, 2}}]trans[{{1, z}}]Tech Notes
Related Guides
Text
Wolfram Research (2017), TransposeLayer, Wolfram Language function, https://reference.wolfram.com/language/ref/TransposeLayer.html (updated 2021).
CMS
Wolfram Language. 2017. "TransposeLayer." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2021. https://reference.wolfram.com/language/ref/TransposeLayer.html.
APA
Wolfram Language. (2017). TransposeLayer. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/TransposeLayer.html
BibTeX
@misc{reference.wolfram_2026_transposelayer, author="Wolfram Research", title="{TransposeLayer}", year="2021", howpublished="\url{https://reference.wolfram.com/language/ref/TransposeLayer.html}", note=[Accessed: 15-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_transposelayer, organization={Wolfram Research}, title={TransposeLayer}, year={2021}, url={https://reference.wolfram.com/language/ref/TransposeLayer.html}, note=[Accessed: 15-June-2026]}