Training plot taking very long to run
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
How can I improve my network to run faster and use less memory.
clc; clear all; close all;
%Import/Upload data
load generated_data.mat
% change to label vector
CS = categories(categorical(Y1));
Z1 = []; Z2 = [];
for i = 1 : length(Y1)
Z1(i,1) = find(Y1(i)==CS);
end
for i = 1 : length(Y2)
Z2(i,1) = find(Y2(i)==CS);
end
Yo1 = Y1;
Yo2 = Y2;
Y1 = Z1;
Y2 = Z2;
%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', [2289,1,1,120]));
%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
%% NETWORK ARCHITECTURE
layers = [imageInputLayer([2289 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('adam', ...
'MaxEpochs',1000, ...
'Shuffle','every-epoch', ...
'Plots','training-progress', ...
'Verbose',false, ...
'ValidationData',{XVal,val_Y1},...
'LearnRateDropFactor',0.2,...
'LearnRateDropPeriod',5,...
'ExecutionEnvironment', 'cpu', ...
'ValidationPatience',Inf);
%% Train network
%net = trainNetwork(XTrain,Trainoutfinal,layers,opts);
yc = train_Y1(:);
net1 = trainNetwork(XTrain,yc,layers,opts);
%% Compare against testing Data
Ypredicted = predict(net1, XTest)
predictionError = test_Y1 - Ypredicted;
squares = predictionError.^2;
rmse = sqrt(mean(squares))
figure
scatter(Ypredicted, test_Y1,'+')
title ('True value vs Predicted Value')
xlabel ("Predicted Value")
ylabel ("True Value")
hold on
plot([-3 3], [-7 7], 'b--')
0 Commenti
Risposta accettata
KSSV
il 21 Dic 2021
You don't plot the progress of training..it will eat away lot of time:
'Plots','training-progress',
USe
'Plots','none',
You can save the progress into a variable and check at the end:
[net1,net1_info] = trainNetwork(XTrain,yc,layers,opts);
0 Commenti
Più risposte (1)
Vedere anche
Categorie
Scopri di più su Image Data Workflows in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!