Autoencoder.encode - Encode input data - MATLAB (original) (raw)

Class: Autoencoder

Syntax

Description

[Z](#buxdn14%5Fsep%5Fshared-Z) = encode([autoenc](#buxdn14%5Fsep%5Fshared-autoenc),[Xnew](#buxdn14%5Fsep%5Fshared-Xnew)) returns the encoded data, Z, for the input data Xnew, using the autoencoder, autoenc.

example

Input Arguments

expand all

Trained autoencoder, returned as an object of the Autoencoder class.

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 x∈ℝDx, then the encoder maps the vector x to another vector z∈ℝD(1) as follows:

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