Main Content

decode

Class:Autoencoder

Decode encoded data

Description

example

Y= decode(autoenc,Z)returns thedecoded dataY, using the autoencoderautoenc.

Input Arguments

expand all

Trained autoencoder, returned by thetrainAutoencoderfunction as an object of theAutoencoderclass.

Data encoded byautoenc, specified as a matrix. Each column ofZrepresents an encoded sample (observation).

Data Types:single|double

Output Arguments

expand all

Decoded data, returned as a matrix or a cell array of image data.

If the autoencoderautoencwas trained on a cell array of image data, thenYis also a cell array of images.

If the autoencoderautoencwas trained on a matrix, thenYis also a matrix, where each column ofYcorresponds to one sample or observation.

Examples

expand all

Load the training data.

X = digitTrainCellArrayData;

Xis 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 using the training data with a hidden size of 15.

hiddenSize = 15; autoenc = trainAutoencoder(X,hiddenSize);

Extract the encoded data for new images using the autoencoder.

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

Decode the encoded data from the autoencoder.

Y = decode(autoenc,features);

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

Algorithms

If the input to an autoencoder is a vector x D x , then the encoder maps the vectorxto another vector z D ( 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 ) × D x is a weight matrix, and b ( 1 ) D ( 1 ) is a bias vector. Then, the decoder maps the encoded representationzback into an estimate of the original input vector,x, as follows:

x ^ = h ( 2 ) ( W ( 2 ) z + b ( 2 ) ) ,

上标(2)代表第二个拉yer. h ( 2 ) : D x D x is the transfer function for the decoder, W ( 1 ) D x × D ( 1 ) is a weight matrix, and b ( 2 ) D x is a bias vector.

Introduced in R2015b