Main Content

堆栈

Class:Autoencoder

Stack encoders from several autoencoders together

Description

堆栈ednet = stack(autoenc1,autoenc2,...)返回一个networkobject created by stacking the encoders of the autoencoders,autoenc1,autoenc2, and so on.

example

堆栈ednet = stack(autoenc1,autoenc2,...,net1)返回一个network object created by stacking the encoders of the autoencoders and the network objectnet1.

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

Input Arguments

expand all

Trained autoencoder, specified as anAutoencoderobject.

Trained autoencoder, specified as anAutoencoderobject.

Trained neural network, specified as anetworkobject.net1can be a softmax layer, trained using thetrainSoftmaxLayerfunction.

Output Arguments

expand all

Stacked neural network (deep network), returned as anetworkobject

Examples

expand all

Load the training data.

[X,T] = iris_dataset;

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');

数字神经网络训练(26-Feb-2022 11:12:05) contains an object of type uigridlayout.

Extract the features in the hidden layer.

features = encode(autoenc,X);

Train a softmax layer for classification using thefeatures.

softnet = trainSoftmaxLayer(features,T);

数字神经网络训练(26-Feb-2022 11:12:34) contains an object of type uigridlayout.

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

堆栈ednet = stack(autoenc,softnet);

View the stacked network.

view(stackednet);

Tips

  • The size of the hidden representation of one autoencoder must match the input size of the next autoencoder or network in the stack.

    The first input argument of the stacked network is the input argument of the first autoencoder. The output argument from the encoder of the first autoencoder is the input of the second autoencoder in the stacked network. The output argument from the encoder of the second autoencoder is the input argument to the third autoencoder in the stacked network, and so on.

  • The stacked network object堆栈netinherits its training parameters from the final input argumentnet1.

Version History

Introduced in R2015b