How to improve LSTM algorithm to extract features of time derivative signal, GPU, deep learning
5 次查看(过去 30 天)
显示 更早的评论
Hi I am working on deep learning tool to desing a technique to classify fault type, im facing difficulty in preparing data type and I dont know why please have a look at my code and advice.
%unamed is 170*244 double type matrix
Daten = unnamed;
[m,n] = size(Daten) ;
%Split into train and test
P = 0.7;
Training = Daten(1:round(P*m),:) ;
Testing = Daten(round(P*m)+1:end,:);
%XTrain is 119*243 double type matrix
XTrain = Training(:,1:n-1);
%YTrain is 119*1 double type matrix
YTrain = Training(:,n);
%XTest is 51*243 double type matrix
XTest = Testing(:,1:n-1);
%YTest is 51*1 double type matrix
YTest = Testing(:,n);
layers = [ ...
sequenceInputLayer(119)
lstmLayer(100,"OutputMode","sequence")
dropoutLayer(0.1)
lstmLayer(100,"OutputMode","last")
fullyConnectedLayer(1)
softmaxLayer
classificationLayer];
options = trainingOptions("adam", ...
"MaxEpochs",150, ...
"MiniBatchSize",miniBatchSize, ...
"Plots","training-progress", ...
"Verbose",false, ...
"Shuffle","every-epoch", ...
"LearnRateSchedule","piecewise", ...
"LearnRateDropFactor",0.1, ...
"LearnRateDropPeriod",20,...
'ValidationData',{XTest,categorical(YTest)});
net = trainNetwork( XTrain , categorical(YTrain) , layers , options);
0 个评论
采纳的回答
Walter Roberson
2020-7-31
编辑:Walter Roberson
2020-8-4
You are splitting up your data by rows, implying that each row is a sample and that the number of features is the one fewer than the number of columns, with the last column being the class.
That is fine as far as it goes, but when you train, the features must go down columns, not across rows.
sequenceInputLayer(119)
That says that you have 119 features, but you do not: you have extracted 119 samples.
You need to transpose, like
XTest = Testing(:,1:n-1) .';
and you need to use
sequenceInputLayer(NumberOfFeatures)
Now, when you use sequenceInputLayer, what you have to pass in as training data is a cell array. The number of entries in the cell array must match the number of entries in the targets you pass in. Each individual cell entry must be an array in which the number of rows is the same as the number of features, and the number of columns is the same as the number of time steps for the sequence -- so each row corresponds to all the time steps for one particular feature.
It is not clear to me that you really do have sequence data.
14 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Data Workflows 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!