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
yanqi liu
yanqi liu 2022년 2월 9일
yes,sir,may be use feat3 as input,of course,its dimension reduce,may be consider use feat1、feat2

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Pattern Recognition and Classification에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by