What is the training accuracy of this model?

6 Ansichten (letzte 30 Tage)
LinkTo
LinkTo am 31 Jul. 2022
Kommentiert: LinkTo am 3 Aug. 2022
I’m trying to classifiy ECG signals using LSTM and MATLAB, the above plot shows that the training accuracy of the system is 100% but when I apply this code to calculate and get the accuracy I get only 20%
LSTMAccuracy = sum(trainPred == Labels)/numel(Labels)*100
Am I missing something here? Or there something wrong I did in my code?
Here is the configuration and the training code:
layers = [ ...
sequenceInputLayer(1)
bilstmLayer(100,'OutputMode','last')
fullyConnectedLayer(5)
softmaxLayer
classificationLayer
]
options = trainingOptions('adam', ...
'MaxEpochs',1750, ...
'MiniBatchSize', 150, ...
'InitialLearnRate', 0.0001, ...
'ExecutionEnvironment',"auto",...
'plots','training-progress', ...
'Verbose',false);
net = trainNetwork(Signals, Labels, layers, options);
trainPred = classify(net, Signals,'SequenceLength',1000);
LSTMAccuracy = sum(trainPred == Labels)/numel(Labels)*100
figure
confusionchart(Labels,trainPred,'ColumnSummary','column-normalized',...
'RowSummary','row-normalized','Title','Confusion Chart for LSTM');
I really appreciate your help, thanks.

Akzeptierte Antwort

Chunru
Chunru am 1 Aug. 2022
If Labels is character array instead of string array, then numel(Labels) will give the number of characters instead of the number of signals intended.
Labels =["abc"; "def"; "ghi"];
numel(Labels)
ans = 3
Labels =['abc'; 'def'; 'ghi'];
numel(Labels)
ans = 9
My guess is that you have a character arrays with 5 characters for each label. If this is the case, use the following
size(Labels, 2)
ans = 3
  9 Kommentare
Chunru
Chunru am 2 Aug. 2022
Try the following:
trainPred = classify(net, Signals,'SequenceLength','longest');
LinkTo
LinkTo am 3 Aug. 2022
It worked. Thank you.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Deep Learning Toolbox finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by