({{, (RefLink[NetDecoder, paclet:ref/NetDecoder])["name"] 
represents a decoder that takes a net representation and decodes it into an expression of a given form.}, {, (RefLink[NetDecoder, paclet:ref/NetDecoder])[{"name",…}]
represents a decoder with additional parameters specified.}})

OpenersNotesSection(Spacer1)Details

(RefLink[NetDecoder, paclet:ref/NetDecoder])[…][array] gives the specified decoded form for array.

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

When given a (RefLink[NumericArray, paclet:ref/NumericArray]) as input, the output will be a (RefLink[NumericArray, paclet:ref/NumericArray]).

Possible named decoders include:

A (RefLink[NetDecoder, paclet:ref/NetDecoder]) object can be attached to an output port of a net by specifying "port"->NetDecoder[…] when constructing the net. Specifying "port"->"type" will create a decoder of the given type and attach it.

When a decoder is attached to the output of a net, net[input] will return the decoded output of the net. The raw output of the net can be obtained by specifying net[input,None].

(RefLink[NetDecoder, paclet:ref/NetDecoder]) is not involved in training done by (RefLink[NetTrain, paclet:ref/NetTrain]). However, when (RefLink[NetTrain, paclet:ref/NetTrain]) is allowed to automatically attach a loss layer and a (RefLink[NetDecoder, paclet:ref/NetDecoder]) is attached to the output of the net, a (RefLink[NetEncoder, paclet:ref/NetEncoder]) of the same type will be created for the "Target" input of the loss layer.

(RefLink[NetDecoder, paclet:ref/NetDecoder])[(RefLink[NetEncoder, paclet:ref/NetEncoder])[…]] will create a decoder based on the parameters of an existing encoder.

OpenersPrimaryExamplesSection(Spacer1)Examples  (5)

OpenersExampleSection0(Spacer1)Basic Examples  (1)

Create a class decoder:

dec=NetDecoder[{"Class",{"a","b","c"}}]

Use it on a probability vector to make a class prediction:

dec[{0.1,0.5,.4}]

Predict the class for a batch of inputs:

dec[{{0.1,0.5,.4},{0.9,0.1,0.0}}]

OpenersExampleSection1(Spacer1)Scope  (1)

Create a pooling layer with an image decoder attached to the output port:

layer=PoolingLayer[3,"Output"->NetDecoder["Image"]]

The layer now returns an image when applied to an input array:

layer[RandomReal[1,{3,50,79}]]

OpenersExampleSection3(Spacer1)Properties & Relations  (2)

Decoders can be attached to a net to automatically decode the output of the net when the net is applied to data:

dec=NetDecoder[{"Class",{a,b,c}}];
net=SoftmaxLayer["Output"->dec]

Apply the net to an input:

net[{1,2,3}]

Apply the net to a batch of inputs:

net[{{3,2,1},{1,2,3}}]

Calculate a property of the decoder for an input:

net[{3,2,1},"Probabilities"]

Calculate a property on a batch of inputs:

net[{{1,1,1},{1,3,9}},"Entropy"]

(RefLink[NetTrain, paclet:ref/NetTrain]) will automatically try to attach a decoder when a net is not fully specified. Automatic attachment of a class decoder:

net=NetTrain[NetChain[{LinearLayer[],SoftmaxLayer[]}],{1.1->"a",2.1->"a",3.3->"b",4.1->"b"}]

NetExtract[net,"Output"]

Automatic attachment of an image decoder:

net=NetTrain[LinearLayer[],{True->,False->,True->,False->}]

NetExtract[net,"Output"]

net[True]

OpenersExampleSection4(Spacer1)Neat Examples  (1)

Use an encoder and a decoder to produce an interactive display of the output of two successive convolutions:

net=NetChain[{
ConvolutionLayer[2,3,"Dilation"->3],Tanh,
ConvolutionLayer[3,3,"Dilation"->3],Tanh
},"Input"->NetEncoder[{"Image",64}],"Output"->"Image"]

net2=NetInitialize[net,Method->{"Random","Weights"->NormalDistribution[0.05,0.2],"Biases"->0.3}];
Dynamic[Image[ImageAdjust@net2 @ CurrentImage[],Magnification->4]]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[NetEncoder, paclet:ref/NetEncoder])  ▪  (RefLink[NetChain, paclet:ref/NetChain])  ▪  (RefLink[NetGraph, paclet:ref/NetGraph])  ▪  (RefLink[NetTrain, paclet:ref/NetTrain])}})}})

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

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Encoding and Decoding Data for Neural Networks, paclet:guide/NetEncoderDecoder])}, {▪(RefLinkPlain[Neural Networks, paclet:guide/NeuralNetworks])}})}})