Unrecognized function or variable 'GR_outputpredicted'. Error in testcnn (line 75) predictionError = test_GR_output - GR_outputpredicted;

1 回表示 (過去 30 日間)
clc; clear all; close all;
%Import/Upload data
load GlucoseReadings.mat
% change to label vector
CS = categories(categorical(GR_output));
Z1 = []; Z2 = [];
for i = 1 : length(GR_output)
Z1(i,1) = find(GR_output(i)==CS);
end
%for i = 1 : length(Y2)
%Z2(i,1) = find(Y2(i)==CS);
%end
Yo1 = GR_output;
%Yo2 = Y2;
GR_output= Z1;
%Y2 = Z2;
%transposing glucose data
GlucoseReadings_T = GlucoseReadings';
%Shuffling data to take randomly
rand('seed', 0)
ind = randperm(size(GlucoseReadings_T, 1));
GlucoseReadings_T = GlucoseReadings_T(ind, :);
GR_output = GR_output(ind);
%Separating data in training, validation and testing data
GlucoseReadings_train = GlucoseReadings_T;
%Partioning data for training 70%
train_GlucoseReadings = GlucoseReadings_train(1:17,:);
%Corresponding X(input) data to Y(output) data
train_GR_output = GR_output(1:17);
%reshaping data into 4D array
GlucoseReadingsTrain=(reshape(train_GlucoseReadings', [1438,1,1,17]));
%Separating and partioning for validation data 15%
val_GlucoseReadings = GlucoseReadings_train(18:22,:);
%Corresponding X(input) data to Y(output) data
val_GR_output = GR_output(18:22);
%reshaping data into 4D array
whos
GlucoseReadingsVal=(reshape(val_GlucoseReadings', [1438,1,1,5])); %Train data
%Separating and partioning for test data 15%
test_GlucoseReadings = GlucoseReadings_train(21:24,:);
%Corresponding X(input) data to Y(output) data
test_GR_output = GR_output(19:24);
%reshaping data into 4D array
GlucoseReadingsTest=(reshape(test_GlucoseReadings', [1438,1,1,4])); %Train data
%% NETWORK ARCHITECTURE
layers = [imageInputLayer([1438 1 1]) % Creating the image layer
convolution2dLayer([102 1],3,'Stride',1)
batchNormalizationLayer
reluLayer
maxPooling2dLayer(2,'Stride',2,'Padding',[0 0 0 1])
dropoutLayer
fullyConnectedLayer(1)
regressionLayer];
% Specify training options.
opts = trainingOptions('sgdm', ...
'MaxEpochs',1500, ...
'Shuffle','every-epoch', ...
'Plots','training-progress', ...
'Verbose',false, ...
'ValidationData',{GlucoseReadingsVal,val_GR_output},...
'LearnRateDropFactor',0.2,...
'LearnRateDropPeriod',5,...
'ExecutionEnvironment', 'cpu', ...
'ValidationPatience',Inf);
%% Train network
%net = trainNetwork(XTrain,Trainoutfinal,layers,opts);
yc = train_GR_output(:);
net1 = trainNetwork(GlucoseReadingsTrain,yc,layers,opts);
%% Compare against testing Data
GR_ouputpredicted = predict(net1, GlucoseReadingsTest)
predictionError = test_GR_output - GR_outputpredicted;
squares = predictionError.^2;
rmse = sqrt(mean(squares))
figure
scatter(GR_outputpredicted, test_GR_output,'+')
title ('True value vs Predicted Value')
xlabel ("Predicted Value")
ylabel ("True Value")
hold on
plot([-3 3], [-7 7], 'b--')

採用された回答

Richard
Richard 2022 年 2 月 22 日
As the error message says, the variable you tried to use does not exist.
You have a typo on line 74. You have created GR_ouputpredicted which is not the same name as GR_outputpredicted on line 75.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeRecognition, Object Detection, and Semantic Segmentation についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by