How to train dataset after dimension reduced with autoencoder into a support vector machine?

2 次查看(过去 30 天)
I am doing a anomaly detection by using stacked autoencoder and one-class svm. The stacked autoencoder is done. The problem is I am unsure of how to use the dimension reduced data after the autoencoder to be trained in the one-class svm?
Here's the code for the stacked autoencoder:
train1 = fullfile(dataFolder, "train_FD001.txt");
[train_data1, train_labels1] = importdata(train1)
% To avoid results from training are different each time
% Explicitly set the random number generator seed
rng('default')
% Specifying the values for the regularizers for the training
%autoenc1 = trainAutoencoder(train_data1,hiddenSize1, ...
autoenc1 = trainAutoencoder(train_data1,100,'MaxEpochs',400,'L2WeightRegularization',1.0, ...
'DecoderTransferFunction','purelin','UseGPU',true)
% Visualize the first autoencoder
view(autoenc1)
% Train the next autoencoder on a set of these vectors extracted from the training data.
% First, you must use the encoder from the trained autoencoder to generate the features.
feat1 = encode(autoenc1,train_data1)
% Specifying the values for the regularizers for the training
autoenc2 = trainAutoencoder(feat1,10,'MaxEpochs',400,...
'DecoderTransferFunction','purelin','UseGPU',true)
% Visualize the second autoencoder
view(autoenc2)
% Train the next autoencoder on a set of these vectors extracted from the training data.
% First, you must use the encoder from the trained autoencoder to generate the features.
feat2 = encode(autoenc2,feat1)
% Specifying the values for the regularizers for the training
autoenc3 = trainAutoencoder(feat2,1,'MaxEpochs',400,...
'DecoderTransferFunction','purelin','UseGPU',true)
% Visualize the third autoencoder
view(autoenc3)
% Train the next autoencoder on a set of these vectors extracted from the training data.
% First, you must use the encoder from the trained autoencoder to generate the features.
feat3 = encode(autoenc3,feat2)
%% Training the final softmax layer
% Train a softmax layer to classify the 50-dimensional feature vectors.
% Unlike the autoencoders, you train the softmax layer in a supervised fashion using labels for the training data.
softnet = trainSoftmaxLayer(feat3,train_data1,'MaxEpochs',400)
% Vizualize the diagram of the softmax layer
view(softnet)
%% Forming a stacked neural network
stackednet = stack(autoenc1,autoenc2,autoenc3,softnet)
% Vizualize the stacked autoencoder
view(stackednet)

回答(1 个)

yanqi liu
yanqi liu 2022-2-8
yes,sir,may be use the encoder net to get data low dimension vector as feature,reshape them to feature matrix and label vector,then train it in new svm model
  8 个评论

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Deep Learning Toolbox 的更多信息

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by