NetEncoder

Listing of Net Encoders »

NetEncoder["name"]

represents an encoder that takes a given form of input and encodes it as an array 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.
  • When given a NumericArray as input, the output will be a NumericArray.
  • 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
    "FeatureExtractor"encode any kind of input as in FeatureExtraction
    "Function"use a custom function to encode an input
    "Image"encode a 2D image as a rank-3 array
    "Image3D"encode a 3D image as a rank-4 array
    "SubwordTokens"encode tokens in a string as a sequence of integer codes
    "Tokens"encode tokens in a string as a sequence of integer codes
    "UTF8"encode strings as their UTF8 bytes
    "VideoFrames"encode a video as a sequence of rank-3 arrays
  • 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.
  • If the input to a NetEncoder is already in the correct form, the NetEncoder will be bypassedthat is, applying a NetEncoder twice has no effect.
  • 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:

Apply the encoder to an input:

The encoder maps across a batch of inputs:

Scope  (1)

An encoder can be attached to the input port of a net. First, create an encoder:

Attach the encoder to the input of an ElementwiseLayer:

Apply the layer directly to an image:

Properties & Relations  (3)

Attaching an encoder ensures that the sizes of all parameters and inputs can be inferred:

A specific size of array can also be specified, without using an encoder:

NetTrain will automatically try to attach an encoder when a net is not fully specified. Automatic attachment of a class encoder:

Automatic attachment of an image encoder:

Applying a NetEncoder a second time is a no-op:

Wolfram Research (2016), NetEncoder, Wolfram Language function, https://reference.wolfram.com/language/ref/NetEncoder.html (updated 2022).

Text

Wolfram Research (2016), NetEncoder, Wolfram Language function, https://reference.wolfram.com/language/ref/NetEncoder.html (updated 2022).

CMS

Wolfram Language. 2016. "NetEncoder." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2022. https://reference.wolfram.com/language/ref/NetEncoder.html.

APA

Wolfram Language. (2016). NetEncoder. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/NetEncoder.html

BibTeX

@misc{reference.wolfram_2024_netencoder, author="Wolfram Research", title="{NetEncoder}", year="2022", howpublished="\url{https://reference.wolfram.com/language/ref/NetEncoder.html}", note=[Accessed: 21-November-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_netencoder, organization={Wolfram Research}, title={NetEncoder}, year={2022}, url={https://reference.wolfram.com/language/ref/NetEncoder.html}, note=[Accessed: 21-November-2024 ]}