Trying reduce overfitting of training plot
    5 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    Nathaniel Porter
 el 4 de Mzo. de 2022
  
    
    
    
    
    Comentada: Nathaniel Porter
 el 7 de Mzo. de 2022
            Previoulsy tried running network with two sets of data however was not succesful. Achieved progres with running one per dataset however want to know how I can reduce any overfitting even though the validation accuracy seems good. 
clc; clear all; close all;
%Import/Upload data
load Projectdata.mat
% change to label vector
CS1 = categories(categorical(INS_output));
Z2 = [];
for i = 1 : length(INS_output)
    Z2(i,1) = find(INS_output(i)==CS1);
end
Yo2 = INS_output;
INS_output = Z2;
%transposing insulin data
InsulinReadings_T = InsulinReadings';
rand('seed', 0)
ind = randperm(size(InsulinReadings_T, 1));
InsulinReadings_T = InsulinReadings_T(ind, :);
INS_output = INS_output(ind);
InsulinReadings_train = InsulinReadings_T;
train_InsulinReadings = InsulinReadings_train(1:84,:);
train_INS_output = INS_output(1:84);
InsulinReadingsTrain=(reshape(train_InsulinReadings',[1758,1,1,84]));
val_InsulinReadings = InsulinReadings_train(85:102,:);
val_INS_output = INS_output(85:102);
InsulinReadingsVal=(reshape(val_InsulinReadings', [1758,1,1,18]));
test_InsulinReadings = InsulinReadings_train(103:120,:);
test_INS_output = INS_output(103:120);
InsulinReadingsTest=(reshape(test_InsulinReadings', [1758,1,1,18]));
%% NETWORK ARCHITECTURE
layers = [imageInputLayer([1758 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',500, ...
    'Shuffle','every-epoch', ...
    'Plots','training-progress', ...
    'Verbose',false, ...
    'ValidationData',{InsulinReadingsVal,val_INS_output,},...
    'LearnRateDropFactor',0.2,...
    'LearnRateDropPeriod',5,...
    'ExecutionEnvironment', 'cpu', ...
    'ValidationPatience',Inf);
%% Train network
%net = trainNetwork(XTrain,Trainoutfinal,layers,opts);
yc1 = train_INS_output(:);
net2 = trainNetwork(InsulinReadingsTrain,yc1,layers,opts);
%% Compare against testing Data
INS_outputpredicted = predict(net2, InsulinReadingsTest)
predictionError = test_INS_output - INS_outputpredicted;
squares = predictionError.^2;
rmse = sqrt(mean(squares))
figure
scatter(INS_outputpredicted, test_INS_output,'+')
title ('True value vs Predicted Value')
xlabel ("Predicted Value")
ylabel ("True Value")
hold on
plot([-3 3], [-7 7], 'b--')
3 comentarios
  Ive J
      
 el 5 de Mzo. de 2022
				Your train and validation sets should be non-overlapping, and if this is the case here (as should be), your model is protected against overfitting simply because train/validation sets never met each other. 
Respuesta aceptada
  yanqi liu
      
 el 7 de Mzo. de 2022
        may be set dropoutLayer(value) to reduce more parameters during training
Más respuestas (0)
Ver también
Categorías
				Más información sobre Deep Learning Toolbox en Help Center y File Exchange.
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!