Autoencoder.decode - Decode encoded data - MATLAB (original) (raw)
Class: Autoencoder
Syntax
Description
Input Arguments
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
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
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 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. Then, the decoder maps the encoded representation z back into an estimate of the original input vector, x, as follows:
where the superscript (2) represents the second layer. h(2):ℝDx→ℝDx 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