Trying to get validation and test accuracy on plot
4 次查看(过去 30 天)
显示 更早的评论
clc; clear all; close all;
%Import/Upload data
load 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);
0 个评论
采纳的回答
更多回答(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!