Trying to get validation and test accuracy on plot

2 Ansichten (letzte 30 Tage)
Nathaniel Porter
Nathaniel Porter am 16 Dez. 2021
Kommentiert: Nathaniel Porter am 16 Dez. 2021
clc; clear all; close all;
%Import/Upload data
load generated_data.mat
Error using load
Unable to find file or directory 'generated_data.mat'.
%transposing glucose data
X1_T = X1';
%Shuffling data to take randomly
rand('seed', 0)
ind = randperm(size(X1_T, 1));
X1_T = X1_T(ind, :);
Y1 = Y1(ind);
%Separating data in training, validation and testing data
X1_train = X1_T;
%Partioning data for training 70%
train_X1 = X1_train(1:120,:);
%Corresponding X(input) data to Y(output) data
train_Y1 = Y1(1:120);
%reshaping data into 4D array
XTrain=(reshape(train_X1, [120,1,1,2289]));
%Separating and partioning for validation data 15%
val_X1 = X1_train(121:150,:);
%Corresponding X(input) data to Y(output) data
val_Y1 = Y1(121:150);
%reshaping data into 4D array
XVal=(reshape(val_X1', [2289,1,1,30])); %Train data
%Separating and partioning for test data 15%
test_X1 = X1_train(151:180,:);
%Corresponding X(input) data to Y(output) data
test_Y1 = Y1(151:180);
%reshaping data into 4D array
XTest=(reshape(test_X1', [2289,1,1,30])); %Train data
%The number of features chosen to be two representing both glucose and
%insulin
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)
lstmLayer(numHiddenUnits)
fullyConnectedLayer(numClasses)
softmaxLayer
classificationLayer];
options = trainingOptions('sgdm', ...
'MaxEpochs',60, ...
'GradientThreshold',2, ...
'Verbose',false, ...
'ValidationData',{XVal,val_Y1},...
'TestData',{XTest,test_Y1},...
'LearnRateDropFactor',0.2, ...
'LearnRateDropPeriod',5, ...
'Plots','training-progress');
net = trainNetwork(X1_train',categorical(Y1),layers,options);

Akzeptierte Antwort

yanqi liu
yanqi liu am 16 Dez. 2021
yes,sir
'TestData',{XTest,test_Y1}
can not configure in trainingOptions

Weitere Antworten (0)

Produkte


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by