({{, (RefLink[NetDecoder, paclet:ref/NetDecoder])["Boolean"]
represents a decoder that converts a probability p to (RefLink[False, paclet:ref/False]) if p<0.5, and (RefLink[True, paclet:ref/True]) otherwise.}})

OpenersNotesSection(Spacer1)Details

(RefLink[NetDecoder, paclet:ref/NetDecoder])[…][input] applies the decoder to an input to produce an output.

(RefLink[NetDecoder, paclet:ref/NetDecoder])[…][{(Subscript[input, 1]),(Subscript[input, 2]),…}] applies the decoder to a list of inputs to produce a list of outputs.

The input to the decoder input is a scalar in the range 0≤input≤1.

(RefLink[NetDecoder, paclet:ref/NetDecoder])[{"Boolean","InputDepth"->n}] can be used to specify that the input array has depth n. The default depth is 0, indicating that the input is a single real number.

A decoder can be attached to an output port of a net by specifying "port"->(RefLink[NetDecoder, paclet:ref/NetDecoder])[…] when constructing the net.

(RefLink[NetDecoder, paclet:ref/NetDecoder])[(StringTypeLink["Boolean", paclet:ref/interpreter/Boolean])][data,prop] can be used to calculate a specific property for the input data.

When a (StringTypeLink["Boolean", paclet:ref/interpreter/Boolean]) decoder is attached to a net, net[data,prop] or net[data,"oport"->prop] can be used to calculate a specific property of the decoded output.

The (StringTypeLink["Boolean", paclet:ref/interpreter/Boolean]) decoder supports the following properties prop:

OpenersPrimaryExamplesSection(Spacer1)Examples  (3)

OpenersExampleSection0(Spacer1)Basic Examples  (1)

Create a Boolean decoder:

dec=NetDecoder["Boolean"]

Decode a probability as either (RefLink[True, paclet:ref/True]) or (RefLink[False, paclet:ref/False]):

dec[0.2]

The decoder maps over a batch of examples:

dec[{0.2,0.9,0.5}]

The decoder expects probabilities as inputs and acts as (RefLink[Identity, paclet:ref/Identity]) with the property "Probability":

dec[{0.2,0.9,0.5},"Probability"]

Compute the entropy:

dec[{0.2,0.9,0.5},"Entropy"]

OpenersExampleSection1(Spacer1)Scope  (2)

Attach a "Boolean" decoder to the output port of an (RefLink[ElementwiseLayer, paclet:ref/ElementwiseLayer]):

layer=ElementwiseLayer[LogisticSigmoid,"Output"->NetDecoder["Boolean"]]

Apply the layer to an input:

layer[3]

Create a "Boolean" decoder that converts a matrix of probabilities into a matrix of Boolean values:

decoder=NetDecoder[{"Boolean","InputDepth"->2}]

Attach the decoder to a net and apply it to an input:

layer=NetInitialize@NetChain[{{3,3},LogisticSigmoid},"Input"->"Real","Output"->decoder]

layer[10.0]

Obtain the probability of the positive class:

layer[10.0,"Probability"]

Compute the entropy of each Bernoulli distribution:

layer[10.0,"Entropy"]

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

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

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