<p>The problem can be solved using the following line of code:</p>
<pre><code>trainPred = classify(net, Signals,'SequenceLength','longest');
</code></pre>

CC BY-SA 4.0
2022-08-03T22:04:46.323Z
Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer).
Community
CC BY-SA 4.0
2022-08-03T20:00:09.997Z
2022-08-03T20:00:09.997Z
LinkToPhD
<p><a href="https://i.sstatic.net/vkDm6.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/vkDm6.png" alt="enter image description here" /></a></p>
<p>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%</p>
<pre><code>LSTMAccuracy = sum(trainPred == Labels)/numel(Labels)*100
</code></pre>
<p><a href="https://i.sstatic.net/9UZLB.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/9UZLB.png" alt="enter image description here" /></a></p>
<p>Am I missing something here? Or there something wrong I did in my code?</p>
<p>Here is the configuration and the training code:</p>
<pre><code>layers = [ ...
    sequenceInputLayer(1)
    bilstmLayer(100,'OutputMode','last') 
    fullyConnectedLayer(5)
    softmaxLayer
    classificationLayer
    ]

options = trainingOptions('adam', ...
    'MaxEpochs',1750, ...
    'MiniBatchSize', 150, ...
    'InitialLearnRate', 0.0001, ...
    'ExecutionEnvironment',&quot;auto&quot;,...
    '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');
</code></pre>

<machine-learning><deep-learning><long-short-term-memory><signal-processing><matlab>
What is the training accuracy of this model?
LinkToPhD
# What is the training accuracy of this model?

(Asked by: username_0 on 2022-07-31)

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

**Tags:** machine-learning, deep-learning, long-short-term-memory, signal-processing, matlab


---

## 1 answers

### Answer by username_0 on 2022-08-03. Score: 0 | Accepted answer

The problem can be solved using the following line of code:
trainPred = classify(net, Signals,'SequenceLength','longest');

> **Comments:**
> **username_1**: Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer).  

---

