Trying to get 80% and greater accuracy from network. Can someone help in editing my code to reach to 80% or close too?
Ältere Kommentare anzeigen
clc; clear all; close all;
load generated_data.mat
% 2289*180
% 6 classes
X1_T = X1';
rand('seed', 0)
ind = randperm(size(X1_T, 1));
X1_T = X1_T(ind, :);
Y1 = categorical(Y1(ind));
% Split Data
X1_train = X1_T;
train_X1 = X1_train(1:120,:);
train_Y1 = Y1(1:120);
% Data Batch
XTrain=(reshape(train_X1', [2289,120]));
val_X1 = X1_train(121:150,:);
val_Y1 = Y1(121:150);
XVal=(reshape(val_X1', [2289,30]));
test_X1 = X1_train(151:180,:);
test_Y1 = Y1(151:180);
XTest=(reshape(test_X1', [2289,30]));
numFeatures = size(X1_T,2);
% number of hidden units represent the size of the data
numHiddenUnits = 180;
%number of classes represent different patients normal,LIS,type2....
numClasses = length(categories(categorical(Y1)));
layers = [ ...
sequenceInputLayer(numFeatures)
dropoutLayer(0.1)
bilstmLayer(numHiddenUnits,'OutputMode','sequence')
fullyConnectedLayer(numClasses)
instanceNormalizationLayer
softmaxLayer
classificationLayer];
options = trainingOptions('sgdm', ...
'MaxEpochs',150, ...
'GradientThreshold',1, ...
'Verbose',false, ...
'ValidationData',{XVal, val_Y1},...
'LearnRateDropFactor',0.2,...
'LearnRateDropPeriod',5,...
'Plots','training-progress');
% Train
net = trainNetwork(XTrain,train_Y1,layers,options);
% Test
miniBatchSize = 27;
YPred = classify(net,XTest, ...
'MiniBatchSize',miniBatchSize,...
'ExecutionEnvironment', 'cpu');
acc = mean(YPred(:) == categorical(test_Y1(:)))
figure
t = confusionchart(categorical(test_Y1(:)),YPred(:));
2 Kommentare
KSSV
am 16 Dez. 2021
An explanation about the problem will help us to help you.
Nathaniel Porter
am 16 Dez. 2021
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Image Data Workflows finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
