represents a net layer that effectively applies Ordering to its input.
gives the first n elements in the ordering of its input.
OrderingLayer[-n]
gives the last n elements in the ordering of its input.
OrderingLayer
represents a net layer that effectively applies Ordering to its input.
gives the first n elements in the ordering of its input.
OrderingLayer[-n]
gives the last n elements in the ordering of its input.
Details and Options
- OrderingLayer[…][input] explicitly computes the output from applying the layer to input.
- OrderingLayer[…][{input1,input2,…}] explicitly computes outputs for each of the inputi.
- When given a NumericArray as input, the output will be a NumericArray.
- OrderingLayer exposes the following ports for use in NetGraph etc.:
-
"Input" a vector "Output" a vector of integer positions - OrderingLayer is typically used inside NetChain, NetGraph, etc.
- OrderingLayer normally infers the size of its input from its context in NetChain etc. The length l of the input vector can be specified using OrderingLayer["Input"l].
- OrderingLayer["Input"shape] allows the shape of the input port to be specified. Possible forms of shape are:
-
l a vector of length l "Varying" a vector whose length is variable NetEncoder[…] an encoder - OrderingLayer[] is equivalent to OrderingLayer[All].
- OrderingLayer performs the same computation as Ordering.
- Options[OrderingLayer] gives the list of default options to construct the layer. Options[OrderingLayer[…]] gives the list of default options to evaluate the layer on some data.
- Information[OrderingLayer[…]] gives a report about the layer.
- Information[OrderingLayer[…],prop] gives the value of the property prop of OrderingLayer[…]. Possible properties are the same as for NetGraph.
Examples
open all close allBasic Examples (1)
Create an OrderingLayer:
o = OrderingLayer[]o[{4.5, 1.2, 5.8, 9.9, 0.7}]Scope (3)
Arguments (2)
Create an OrderingLayer that returns the positions of the 4 smallest elements:
o = OrderingLayer[4]o[{4.5, 1.2, 5.8, 9.9, 0.7, -0.7, 8.2, -8.6}]Create an OrderingLayer that returns the positions of the 4 largest elements:
o = OrderingLayer[-4]o[{4.5, 1.2, 5.8, 9.9, 0.7, -0.7, 8.2, -8.6}]Ports (1)
Create an OrderingLayer that returns the positions of the 4 smallest elements and takes a vector of length 8:
o = OrderingLayer[4, "Input" -> 8]o[{4.5, 1.2, 5.8, 9.9, 0.7, -0.7, 8.2, -8.6}]Apply the layer to a batch of vectors:
o[{{4.5, 1.2, 5.8, 9.9, 0.7, -0.7, 8.2, -8.6}, {7.4, 5.5, 6.7, 2.1, 9.2, 6.5, 7.2, 9.7}}]Properties & Relations (1)
OrderingLayer performs the same computation as Ordering:
data = RandomReal[1, 10]OrderingLayer[][data]Ordering[data]Tech Notes
Related Guides
History
Text
Wolfram Research (2019), OrderingLayer, Wolfram Language function, https://reference.wolfram.com/language/ref/OrderingLayer.html.
CMS
Wolfram Language. 2019. "OrderingLayer." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/OrderingLayer.html.
APA
Wolfram Language. (2019). OrderingLayer. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/OrderingLayer.html
BibTeX
@misc{reference.wolfram_2026_orderinglayer, author="Wolfram Research", title="{OrderingLayer}", year="2019", howpublished="\url{https://reference.wolfram.com/language/ref/OrderingLayer.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_orderinglayer, organization={Wolfram Research}, title={OrderingLayer}, year={2019}, url={https://reference.wolfram.com/language/ref/OrderingLayer.html}, note=[Accessed: 13-June-2026]}