Invalid training data. Sequence responses must have the same sequence length as the corresponding predictors.
古いコメントを表示
Confused as to why categorical did nto work is there somwhere else that I need to fix
clc; clear all; close all;
load Projectdata.mat
% Split Data Glucose
GlucoseReadings_T = GlucoseReadings';
GlucoseReadings_train = GlucoseReadings_T;
train_GlucoseReadings = GlucoseReadings_train(1:84,:);
train_GR_output = GR_output(1:17);
% Data Batch Glucose
GlucoseReadingsTrain=(reshape(train_GlucoseReadings', [1749,84]));
val_GlucoseReadings = GlucoseReadings_train(85:102,:);
val_GR_output = GR_output(85:102);
GlucoseReadingsVal=(reshape(val_GlucoseReadings', [1749,18]));
test_GlucoseReadings =GlucoseReadings_train(103:120,:);
test_GR_output = GR_output(103:120);
GlucoseReadingsTest=(reshape(test_GlucoseReadings', [1749,18]));
numFeatures = size(GlucoseReadings_T,2);
% number of hidden units represent the size of the data
numHiddenUnits = 120;
%number of classes repsresnt healthy and diabetic
numClasses = length(categories(categorical(GR_output)));
layers = [ ...
sequenceInputLayer(numFeatures)
%dropoutLayer(0.5)
instanceNormalizationLayer
bilstmLayer(round(numHiddenUnits/2),'OutputMode','sequence')
fullyConnectedLayer(numClasses)
instanceNormalizationLayer
softmaxLayer
classificationLayer];
options = trainingOptions('adam', ...
'MaxEpochs',100, ...
'GradientThreshold',1, ...
'Verbose',false, ...
'ValidationData',{GlucoseReadingsVal, val_GR_output},...
'LearnRateDropFactor',0.2,...
'LearnRateDropPeriod',5,...
'Plots','training-progress');
% Train
whos
net = trainNetwork(GlucoseReadingsTrain,categorical(train_GR_output),layers,options);
% Test
miniBatchSize = 27;
GR_outputPred = classify(net,GlucoseReadingsTest,...
'MiniBatchSize',miniBatchSize,...
'Environment','cpu');
acc = mean(GR_outputPred(:) == categorical(test_GR_output(:)))
figure
t = confusionchart(categorical(test_GR_output(:)),GR_outputPred(:));
figure
t1 = confusionchart(categorical(test_INS_output(:)),INS_outputPred(:));
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Preprocess Data for Deep Neural Networks についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!