Wolfram Language & System 11.0 (2016)|Legacy Documentation

This is documentation for an earlier version of the Wolfram Language.View current documentation (Version 11.2)

NetEncoder

NetEncoder[type]
represents an encoder that takes a given type of input and encodes it as a tensor for use in a net.

DetailsDetails

  • A NetEncoder object can be attached to an input port of a net by specifying "port"->NetEncoder[] when constructing the net. Specifying "port"->"type" will create an encoder of the given type and attach it.
  • Possible types include:
  • "Scalar"a single numeric value
    "Image"any image
    {"Image",{w,h}}image encoded with width w and height h
    {"Image",opts}image with specified encoding options
    {"Class",{c1,c2,}}classes ci encoded as integers or unit vectors
    "Boolean"True and False encoded as 1 and 0
  • NetEncoder[{"Class",{c1,c2,},form}] can be used to specify the form of output from the encoder. Possible forms include:
  • "Index"encode ci as integer i (default)
    "UnitVector"encode ci as the ith unit vector
  • NetEncoder[][input] gives the specified encoding for input.
  • NetEncoder[][{input1,input2, }] explicitly computes outputs for each of the inputi.
  • Possible options to specify how an image should be converted before encoding include:
  • "ImageSize"Automaticimage size to use for encoding
    "ColorChannels"Automaticcolor channels to use for encoding
    "ColorSpace""RGB"color space to use for encoding
    "MeanImage"Nonemean image to subtract
  • The following settings can be used for "MeanImage":
  • Nonedo not subtract anything
    mvalue to subtract from each channel of each pixel
    {m1,m2,}values to be subtracted from different channels
    Image[]overall image to subtract
  • Pixels are normalized to the range 0, 1 before doing subtraction.

ExamplesExamplesopen allclose all

Basic Examples  (4)Basic Examples  (4)

Create a scalar encoder:

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

Encode a numeric value as a vector of length 1:

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

Encode a list of values at once:

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

Create an image encoder of size 8×8:

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

Encode an image:

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

The output has dimensions given by the number of channels and the height and width specified in the encoder:

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

Create a class encoder:

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

Use it to encode a member of the class:

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

Encode a list of inputs at once:

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

Create a Boolean encoder:

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

Use it to encode inputs:

In[2]:=
Click for copyable input
Out[2]=
Introduced in 2016
(11.0)