NetEncoder

NetEncoder["name"]

represents an encoder that takes a given form of input and encodes it as a tensor for use in a net.

NetEncoder[{"name",}]

represents an encoder with additional parameters specified.

Details

  • NetEncoder[][input] gives the specified encoding for input.
  • NetEncoder[][{input1,input2, }] explicitly computes outputs for each of the inputi.
  • Possible named encoders include:
  • "Audio"encode audio as a sequence of waveform amplitudes
    "AudioMelSpectrogram"encode audio as a mel spectrogram
    "AudioMFCC"encode audio as a sequence of MFCC vectors
    "AudioSpectrogram"encode audio as a spectrogram
    "AudioSTFT"encode audio as a sequence of Fourier transforms
    "Boolean"encode True and False as 1 and 0
    "Characters"encode characters in a string as a sequence of integer codes or one-hot vectors
    "Class"encode a class label as an integer code or a one-hot vector
    "Function"use a custom function to encode an input
    "Image"encode a 2D image as a 3-tensor
    "Image3D"encode a 3D image as a 4-tensor
    "Scalar"encode a single numeric value as a 1-vector
    "Tokens"encode tokens in a string as a sequence of integer codes or one-hot vectors
  • A NetEncoder object can be attached to an input port of a net by specifying "port"->NetEncoder[] when constructing the net. Specifying "port"->"name" will create an encoder using NetEncoder["name"] and attach it.
  • When NetTrain is allowed to automatically attach a loss layer and a NetDecoder is attached to the output of the net, a NetEncoder of the same type will be created for the "Target" input of the loss layer.
  • NetEncoder[NetDecoder[]] will create an encoder based on the parameters of an existing decoder.

Examples

open allclose all

Basic Examples  (1)

Create a class encoder:

In[1]:=
Click for copyable input
Out[1]=

Apply the encoder to an input:

In[2]:=
Click for copyable input
Out[2]=

The encoder maps across a batch of inputs:

In[3]:=
Click for copyable input
Out[3]=

Scope  (1)

Properties & Relations  (2)

See Also

NetDecoder  NetChain  NetGraph  NetTrain

Tutorials

Introduced in 2016
(11.0)
| Updated in 2018
(11.3)