({{, (RefLink[PartLayer, paclet:ref/PartLayer])[i]
represents a net layer that gives the i(^th) part of the input.}, {, (RefLink[PartLayer, paclet:ref/PartLayer])[m;;n]
gives parts m through n.}, {, (RefLink[PartLayer, paclet:ref/PartLayer])[{(Subscript[spec, 1]),(Subscript[spec, 2]),…}]
takes part (Subscript[spec, i]) at level i in the input.}})

OpenersNotesSection(Spacer1)Details and Options

(RefLink[PartLayer, paclet:ref/PartLayer])[…][input] explicitly computes the output from applying the layer to input.

(RefLink[PartLayer, paclet:ref/PartLayer])[…][{(Subscript[input, 1]),(Subscript[input, 2]),…}] explicitly computes outputs for each of the (Subscript[input, i]).

(RefLink[PartLayer, paclet:ref/PartLayer]) exposes the following ports for use in (RefLink[NetGraph, paclet:ref/NetGraph]) etc.:

(RefLink[PartLayer, paclet:ref/PartLayer]) is typically used inside (RefLink[NetChain, paclet:ref/NetChain]), (RefLink[NetGraph, paclet:ref/NetGraph]), etc.

(RefLink[PartLayer, paclet:ref/PartLayer]) normally infers the dimensions of its input from its context in (RefLink[NetChain, paclet:ref/NetChain]) etc. To specify the dimensions explicitly as {(Subscript[n, 1]),(Subscript[n, 2]),…}, use (RefLink[PartLayer, paclet:ref/PartLayer])["Input"->{(Subscript[n, 1]),(Subscript[n, 2]),…}].

(RefLink[PartLayer, paclet:ref/PartLayer])[m;;n] gives an output that is of the same rank as the input, whereas (RefLink[PartLayer, paclet:ref/PartLayer])[i] gives an output that is one rank smaller.

OpenersPrimaryExamplesSection(Spacer1)Examples  (8)

OpenersExampleSection0(Spacer1)Basic Examples  (2)

Create a (RefLink[PartLayer, paclet:ref/PartLayer]) that takes the second part of an array:

PartLayer[2]

Create a (RefLink[PartLayer, paclet:ref/PartLayer]) that takes the second part of an array:

p=PartLayer[2]

Apply the layer to a vector:

p[{1,2,3,4,5,6}]

OpenersExampleSection1(Spacer1)Scope  (5)

Create a (RefLink[PartLayer, paclet:ref/PartLayer]) that takes the first two elements:

p=PartLayer[1;;2]

Apply the layer to a matrix:

p[{{1,2},{3,4},{5,6}}]

Create a (RefLink[PartLayer, paclet:ref/PartLayer]) that takes the next-to-last element in an array:

p=PartLayer[-2]

Apply the layer to a vector:

p[{1,2,3,4,5,6}]

Create a (RefLink[PartLayer, paclet:ref/PartLayer]) that takes all elements after the second one:

p=PartLayer[2;;]

Apply the layer to a vector:

p[{-1,-2,-3,-4,-5}]

This is equivalent to using (RefLink[All, paclet:ref/All]):

PartLayer[2;;All][{-1,-2,-3,-4,-5}]

Create a (RefLink[PartLayer, paclet:ref/PartLayer]) whose inputs are vectors of length three:

p=PartLayer[2,"Input"-> 3]

The layer threads across a batch of examples:

p[{{1,2,3},{0.1,0.2,0.3}}]

Create a (RefLink[PartLayer, paclet:ref/PartLayer]) that takes the first column of its input, which is a matrix:

p=PartLayer[{All,1},"Input"->{2,3}]

Apply the layer to a matrix:

p[{{1,2,3},{4,5,6}}]

OpenersExampleSection3(Spacer1)Possible Issues  (1)

Using (RefLink[Part, paclet:ref/Part]) with a (RefLink[Span, paclet:ref/Span]) where the second index is smaller than the first is valid syntax, producing an empty list:

{1,2,3,4}[[3;;2]]

This is invalid syntax for (RefLink[PartLayer, paclet:ref/PartLayer]), as empty arrays are not allowed in nets:

PartLayer[3;;2]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[Part, paclet:ref/Part])  ▪  (RefLink[ExtractLayer, paclet:ref/ExtractLayer])  ▪  (RefLink[ReshapeLayer, paclet:ref/ReshapeLayer])  ▪  (RefLink[FlattenLayer, paclet:ref/FlattenLayer])  ▪  (RefLink[ReplicateLayer, paclet:ref/ReplicateLayer])  ▪  (RefLink[TransposeLayer, paclet:ref/TransposeLayer])  ▪  (RefLink[NetChain, paclet:ref/NetChain])  ▪  (RefLink[NetGraph, paclet:ref/NetGraph])}})}})

({{DocumentationFooterIconsRelatedTutorial.png, ({{Tutorials}, {▪(RefLinkPlain[Neural Networks in the Wolfram Language, paclet:tutorial/NeuralNetworksOverview])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Neural Networks, paclet:guide/NeuralNetworks])}})}})