"Function" (Net Decoder)
NetDecoder[{"Function",f}]
represents a decoder that applies f to the output of a net to obtain a decoded result.
Details
- NetDecoder[{"Function",…}] is typically used to define a custom post-processing for a neural network.
- NetDecoder[…][input] applies the decoder to an input to produce an output.
- NetDecoder[…][{input1,input2,…}] applies the decoder to a list of inputs to produce a list of outputs.
- A decoder can be attached to an output port of a net by specifying "port"->NetDecoder[…] when constructing the net.
- The following parameters are supported:
-
"Properties" {} available properties SaveDefinitions True whether current definitions relevant for the evaluation of the encoder should automatically be saved Initialization None expression to be evaluated when the encoder is first applied ExcludedContexts Automatic contexts whose symbols will not have their definitions recursively saved IncludedContexts All contexts whose symbols will have their definitions recursively saved - NetDecoder[{"Function",f,"Properties"{"prop1","prop2",…}}] can be used to specify that the decoder supports obtaining any of the propi. The function f must then take the property to decode as its second argument. In this case, the default property that will be supplied to f if no specific property is requested is prop1.
- By default, NetDecoder[{"Function",f,…}] saves the definitions of all the symbols needed to evaluate f, and restores these definitions at the first evaluation of the decoder. The selection of definitions to be saved can be changed using options SaveDefinitions, Initialization, ExcludedContexts and IncludedContexts.
Parameters
Examples
open allclose allBasic Examples (1)
Create a property that interprets its input as an RGB color:
Note that the function is passed a NumericArray and that Normal is used to convert it to a standard array that RGBColor can take.
Decode a 3-vector as an RGB color:
Parameters (2)
"Properties" (1)
SaveDefinitions (1)
By default, definitions needed to evaluate the decoder are saved:
When applying the encoder for the first time, definitions are restored:
This behavior can be disabled using SaveDefinitionsFalse:
Possible Issues (1)
Many Wolfram Language functions do not support NumericArray inputs. This issue can be solved by using Normal to convert a NumericArray input to a standard array: