"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[][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.
  • Options
  • 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.

Examples

open allclose all

Basic 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:

Attach the decoder to a randomly generated net:

The output of the net is automatically decoded as a color:

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:

Introduced in 2019
 (12.0)