主要内容

encode

Class: Autoencoder

(To be removed) Encode input data

encode will be removed in a future release. For more information, see Transition Legacy Neural Network Code to dlnetwork Workflows.

For advice on updating your code, see Version History.

Description

Z = encode(autoenc,Xnew) returns the encoded data, Z, for the input data Xnew, using the autoencoder, autoenc.

example

Input Arguments

expand all

Trained autoencoder, specified as an Autoencoder object.

Input data, specified as a matrix of samples, a cell array of image data, or an array of single image data.

If the autoencoder autoenc was trained on a matrix, where each column represents a single sample, then Xnew must be a matrix, where each column represents a single sample.

If the autoencoder autoenc was trained on a cell array of images, then Xnew must either be a cell array of image data or an array of single image data.

Data Types: single | double | cell

Output Arguments

expand all

Data encoded by autoenc, specified as a matrix. Each column of Z represents an encoded sample (observation).

Data Types: single | double

Examples

expand all

Load the sample data.

X = digitTrainCellArrayData;

X is a 1-by-5000 cell array, where each cell contains a 28-by-28 matrix representing a synthetic image of a handwritten digit.

Train an autoencoder with a hidden size of 50 using the training data.

autoenc = trainAutoencoder(X,50);

Encode decoded data for new image data.

Xnew = digitTestCellArrayData;
Z = encode(autoenc,Xnew);

Xnew is a 1-by-5000 cell array. Z is a 50-by-5000 matrix, where each column represents the image data of one handwritten digit in the new data Xnew.

Algorithms

If the input to an autoencoder is a vector xDx, then the encoder maps the vector x to another vector zD(1) as follows:

z=h(1)(W(1)x+b(1)),

where the superscript (1) indicates the first layer. h(1):D(1)D(1) is a transfer function for the encoder, W(1)D(1)×Dx is a weight matrix, and b(1)D(1) is a bias vector.

Version History

Introduced in R2015b

collapse all