필터 지우기
필터 지우기

Trying reduce overfitting of training plot

조회 수: 3 (최근 30일)
Nathaniel Porter
Nathaniel Porter 2022년 3월 4일
댓글: Nathaniel Porter 2022년 3월 7일
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
Nathaniel Porter
Nathaniel Porter 2022년 3월 4일
Due to the significant gap found between the validation line and training line.
Ive J
Ive J 2022년 3월 5일
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.

댓글을 달려면 로그인하십시오.

채택된 답변

yanqi liu
yanqi liu 2022년 3월 7일
may be set dropoutLayer(value) to reduce more parameters during training
  댓글 수: 1
Nathaniel Porter
Nathaniel Porter 2022년 3월 7일
Is a 0.5 dropout layer value good or should increase and determine if it helps

댓글을 달려면 로그인하십시오.

추가 답변 (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