"Class" (Net Encoder)


represents an encoder that converts a class label in the list classes to an integer code.


represents an encoder that converts class labels to the output type form.


  • NetEncoder[][input] applies the encoder to an input to produce an output.
  • NetEncoder[][{input1,input2,}] applies the encoder to a list of inputs to produce a list of outputs.
  • The input to the encoder inputi must be an element in the list classes.
  • When form is "Index" (the default), the output of the encoder is the integer that is the position of input in classes.
  • When form is "UnitVector", the output of the encoder is an n-dimensional unit vector in the p^(th) direction, where p is the position of input in classes, and n is the length of classes.
  • An encoder can be attached to an input port of a net by specifying "port"->TemplateBox[{NetEncoder, paclet:ref/NetEncoder}, RefLink, BaseStyle -> {InlineFormula}][] when constructing the net.


open allclose all

Basic Examples  (1)

Create a class encoder with two classes:

Click for copyable input

Apply it to a batch of inputs:

Click for copyable input

Scope  (1)

Properties & Relations  (1)

See Also

NetEncoder  NetDecoder  NetChain  NetGraph  FeatureExtract  UnitVector


Related NetEncoders

Related NetDecoders