Autoencoder.stack - Stack encoders from several autoencoders together - MATLAB (original) (raw)

Class: Autoencoder

Stack encoders from several autoencoders together

Syntax

Description

stackednet = stack(autoenc1,autoenc2,...) returns a network object created by stacking the encoders of the autoencoders, autoenc1, autoenc2, and so on.

stackednet = stack(autoenc1,autoenc2,...,net1) returns a network object created by stacking the encoders of the autoencoders and the network object net1.

The autoencoders and the network object can be stacked only if their dimensions match.

example

Input Arguments

expand all

Trained autoencoder, specified as an Autoencoder object.

Trained autoencoder, specified as an Autoencoder object.

Trained neural network, specified as a network object. net1 can be a softmax layer, trained using the trainSoftmaxLayer function.

Output Arguments

expand all

Stacked neural network (deep network), returned as a network object

Examples

expand all

Load the training data.

Train an autoencoder with a hidden layer of size 5 and a linear transfer function for the decoder. Set the L2 weight regularizer to 0.001, sparsity regularizer to 4 and sparsity proportion to 0.05.

hiddenSize = 5; autoenc = trainAutoencoder(X, hiddenSize, ... 'L2WeightRegularization', 0.001, ... 'SparsityRegularization', 4, ... 'SparsityProportion', 0.05, ... 'DecoderTransferFunction','purelin');

Figure Neural Network Training (01-Feb-2025 09:12:57) contains an object of type uigridlayout.

Extract the features in the hidden layer.

features = encode(autoenc,X);

Train a softmax layer for classification using the features.

softnet = trainSoftmaxLayer(features,T);

Figure Neural Network Training (01-Feb-2025 09:13:06) contains an object of type uigridlayout.

Stack the encoder and the softmax layer to form a deep network.

stackednet = stack(autoenc,softnet);

View the stacked network.

Tips

Version History

Introduced in R2015b