"Boolean" (Net Encoder)


represents an encoder that converts True to 1 and False to 0.


  • 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 either True or False.
  • The output of the encoder is 0 if input is False, and 1 if input is True. This is equivalent to Boole[inputi].
  • An encoder can be attached to an input port of a net by specifying "port"->NetEncoder[] when constructing the net.


open allclose all

Basic Examples  (1)

Create a Boolean encoder:

Use it to encode an input:

The encoder maps over a batch of examples:

Scope  (1)

Attach a Boolean encoder to the input port of an ElementwiseLayer:

Apply the layer to an input: