Why do I have the same validation accuracy for every epoch?
11 次查看(过去 30 天)
显示 更早的评论
I developed a CNN for ECG arrhythmia classification and when I train the model I obtain the same validation accuracy for all of the 50 epoch. Can you please tell me what is wrong? I tried to modify the parameters, also the structure, but the validation accuracy is unchanged (80.1%).
Labels=cnnLabels(labels); %Divide and add LABELS in classes from 1 to 5
[heartbeats, ~, ~] = featureNormalize(heartbeats); % Normalization
%% Spliting the data in training and testing sets
PercentNumFiles =round(0.90*length(heartbeats)); %90% of the files for training and 10% for testing
trainingPercent=round(0.9*PercentNumFiles);%90% of the training set is used for training and the other 10 for training validation
randomNum(:,1)=randperm(length(heartbeats)); %random selection of the files
Xtrain=heartbeats(randomNum(1:trainingPercent),:);
Xvalidation=heartbeats(randomNum(trainingPercent+1:PercentNumFiles),:);
Xtest=heartbeats(randomNum(PercentNumFiles+1:end),:);
Ytrain=Labels(randomNum(1:trainingPercent));
Yvalidation=Labels(randomNum(trainingPercent+1:PercentNumFiles));
Ytest=Labels(randomNum(PercentNumFiles+1:end));
%% CNN
clear ECG fs ind before after anntype cleanECG PercentNumFiles randomNum
height = 1;
width = 300;
channels = 1;
Xtrain = reshape(Xtrain,[height, width, channels, length(Xtrain)]);
Xvalidation=reshape(Xvalidation,[height, width, channels, length(Xvalidation)]);
Xtest = reshape(Xtest,[height, width, channels, length(Xtest)]);
Ytrain=categorical(Ytrain);
Yvalidation=categorical(Yvalidation);
Ytest=categorical(Ytest);
%% CNN construction
% classes = [1 2 3 4 5];
% classWeights = [0.1 0.7 0.6 0.9 0.3];
classWeights = 1./countcats(Ytrain);
classWeights = classWeights'/mean(classWeights);
Layers=[
imageInputLayer([height,width,channels]); %'DataAugmentation', 'none'); %'Normalization', 'none');
convolution2dLayer([1 3], 256,'stride',[1 1], 'padding','same'); %Filter window size = [1 5], No of filters = 64, stride = [1 1];
convolution2dLayer([1 3], 256,'stride',[1 1], 'padding','same');
reluLayer();
dropoutLayer();
maxPooling2dLayer([1 2],'stride',[1 2]); %PoolSize = [1 2], Stride = [1 1]
convolution2dLayer([1 3], 128,'stride',[1 1], 'padding','same');
reluLayer();
convolution2dLayer([1 3], 128,'stride',[1 1], 'padding','same');
reluLayer();
convolution2dLayer([1 3], 64,'stride',[1 1], 'padding','same');
reluLayer();
dropoutLayer();
maxPooling2dLayer([1 2],'stride',[1 2]); %PoolSize = [1 2], Stride = [1 1]
fullyConnectedLayer(256);
dropoutLayer();
fullyConnectedLayer(128);
fullyConnectedLayer(5); %Reduce to five output classes
softmaxLayer();
classificationLayer();
];
%% Options of training
options = trainingOptions('sgdm','InitialLearnRate',0.001,'MaxEpochs',50, ...
'LearnRateSchedule','piecewise', ...
'LearnRateDropFactor',0.1, ...
'LearnRateDropPeriod', 3,...
'L2Regularizatio',1.0000e-04, ...
'MiniBatchSize', 60,...
'ValidationData',{Xvalidation, Yvalidation},...
'Plots','training-progress');
convnet = trainNetwork(Xtrain,Ytrain,Layers,options);
0 个评论
采纳的回答
Aditya Patil
2021-5-10
As per my understanding, the data you have in unidimensional, and is time variant.
It might be a better option to consider this as a sequence classification problem. Have a look at this example for classifying ECG using LSTMs. There are also video tutorials for the same.
For the current model, it might be predicting the largest class for all the observations. You can check this by looking at the confusion matrix or the outputs.
更多回答(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!