Main Content

decode

Class: Autoencoder

Decode encoded data

Description

Y = decode(autoenc,Z)returns the decoded data Y, using the autoencoder autoenc.

example

Input Arguments

expand all

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

Data encoded by autoenc, specified as a matrix. Each column of Z represents 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 autoencoder autoenc was trained on a cell array of image data, then Y is also a cell array of images.

If the autoencoder autoenc was trained on a matrix, then Y is also a matrix, where each column of Y corresponds to one sample or observation.

Examples

expand all

Load the training 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 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);

Y is 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 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. Then, the decoder maps the encoded representation z back into an estimate of the original input vector, x, as follows:

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

where the superscript (2) represents the second layer. h(2):DxDx is the transfer function for the decoder,W(1)Dx×D(1) is a weight matrix, and b(2)Dx is a bias vector.

Version History

Introduced in R2015b