"Boolean" (Net Encoder)

NetEncoder["Boolean"]

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

NetEncoder[{"Boolean",{d1,d2,,dn}}]

represents an encoder that converts tensors of dimensions d1×d2××dn of Booleans.

Details

  • 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 equivalent to Boole[input].
  • An encoder can be attached to an input port of a net by specifying "port"->NetEncoder[] when constructing the net.

Examples

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  (2)

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

Apply the layer to an input:

Make a NetChain that processes a 3-length vector of Booleans:

Apply the network to an input: