필터 지우기
필터 지우기

Trying to get validation and test accuracy on plot

조회 수: 3 (최근 30일)
Nathaniel Porter
Nathaniel Porter 2021년 12월 16일
댓글: Nathaniel Porter 2021년 12월 16일
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);

채택된 답변

yanqi liu
yanqi liu 2021년 12월 16일
yes,sir
'TestData',{XTest,test_Y1}
can not configure in trainingOptions

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Image Data Workflows에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by