NetDecoder
NetDecoder[type]
represents a decoder that takes a net representation and decodes it into an expression of a given form.
Details
- A 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].
- Possible types include:
-
"Scalar" a single number decoded from a length-1 vector "Image" an RGB image {"Image",ColorSpaces} image with specified color space {"Class",{c1,c2,…}} the ci for which the probability is highest "Boolean" probability of a Boolean variable being True - Possible types for decoding sequences include:
-
"Characters" probabilities of successive characters in a string {"Characters","c1c2…"} probabilities pi for characters ci in a string "Tokens" probabilities of common English words {"Tokens",{"t1","t2",…}} probabilities pi of tokens ti in a string - NetDecoder[…][array] gives the specified decoded form for array.
- NetDecoder[…][{array1,array2, …}] explicitly computes outputs for each of the arrayi.
- With NetDecoder[{"Class", {c1,c2,…}}], the ci typically represent categorical classes in a classifier.
- NetDecoder[{"Class",…}][array,prop] allows the following properties:
-
"Decision" the class ci with the highest probability {"TopDecisions",n} the n classes with the highest probabilities "TopProbabilities" probabilities for the most likely ci, returned as a list of rules {"TopProbabilities",n} probabilities for the n most likely ci "Probabilities" the association <c1->p1,c2->p2,…> {"Probability",ci} probability for a specific ci "Entropy" the entropy of the probability distribution - NetDecoder[{"Characters",spec}] uses the same specifications spec as NetEncoder[{"Characters",spec}].
- NetDecoder["Boolean"] decodes a probability p as True if p>0.5 and False otherwise.
- NetDecoder is not involved in training done by NetTrain. However, when NetTrain is allowed to automatically attach a loss layer and a NetDecoder is attached to the output of the net, a NetEncoder of the same type will be created for the "Target" input of the loss layer.
- NetDecoder[NetEncoder[…]] will create a decoder based on the parameters of an existing encoder.
Examples
open allclose allBasic Examples (6)
Use it on a probability vector to make a class prediction:
Predict the class for a batch of inputs:
Use it to decode a vector of length one to a single scalar value:
Decode a set of vectors at once:
Use it to decode a three-channel matrix as an RGB image:
Create a grayscale image decoder:
Use it to decode a single-channel matrix as a grayscale image:
Decode a probability as either True or False:
Decode a sentence from a one-hot vector representation:
Create a token encoder for English text:
Decode a nonsense sentence from a random matrix of probabilities:
Scope (1)
Properties & Relations (2)
Neat Examples (1)
See Also
Related Guides
Introduced in 2016
(11.0)
| Updated in 2017 (11.1)