multi output multilayer perceptron neural network problem
8 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hi, I am trying to train a multi output multilayer perceptron neural network which has 6 inputs and five outputs. However, after training, the error of the neural network is big. I tried my code when the network has one outout only, and the errors were very small (I trained 5 different neural networks for every 5 output). But when I increase the number of outputs in my neural network, the errors get very big. Can someone please help me with this problem?
clc
clear all
data = readtable('dec.xlsx');
% INPUTS
ps(:,1)=data.Time;
ps(:,2)=data.Supply_Bp ;
ps(:,3)=data.Supply_Bt ;
ps(:,4)=data.s ;
ps(:,5)=data.sm3 ;
ps(:,6)=data.d ;
% OUTPUTS
y1(:,1)=data.P_1 ;
y1(:,2)=data.P_2 ;
y1(:,2)=data.P_3 ;
y1(:,2)=data.P_4 ;
y1(:,2)=data.P_5 ;
% INPUTS OF NEURAL NETWORK
x = ps';
% OUTPUTS OF NEURAL NETWORK
t = y1';
trainFcn = 'trainbr'; % Levenberg-Marquardt backpropagation.
% Create a Fitting Network
hiddenLayerSize = [16 32];
net5 = fitnet(hiddenLayerSize,trainFcn);
% Choose Input and Output Pre/Post-Processing Functions
% For a list of all processing functions type: help nnprocess
net5.input.processFcns = {'removeconstantrows','mapminmax'};
net5.output.processFcns = {'removeconstantrows','mapminmax'};
% Setup Division of Data for Training, Validation, Testing
% For a list of all data division functions type: help nndivision
net5.divideFcn = 'dividerand'; % Divide data randomly
net5.divideMode = 'sample'; % Divide up every sample
net5.divideParam.trainRatio = 70/100;
net5.divideParam.valRatio = 10/100;
net5.divideParam.testRatio = 20/100;
% Choose a Performance Function
% For a list of all performance functions type: help nnperformance
net5.performFcn = 'mse'; % Mean Squared Error
% Choose Plot Functions
% For a list of all plot functions type: help nnplot
net5.plotFcns = {'plotperform','plottrainstate','ploterrhist', ...
'plotregression', 'plotfit'};
% Train the Network
[net5,tr] = train(net5,x,t);
% Test the Network
y = net5(x);
e = gsubtract(t,y);
performance = perform(net5,t,y);
% Recalculate Training, Validation and Test Performance
trainTargets = t .* tr.trainMask{1};
valTargets = t .* tr.valMask{1};
testTargets = t .* tr.testMask{1};
trainPerformance = perform(net5,trainTargets,y);
valPerformance = perform(net5,valTargets,y);
testPerformance = perform(net5,testTargets,y);
% View the Network
view(net5)
if (false)
% Generate MATLAB function for neural network for application
% deployment in MATLAB scripts or with MATLAB Compiler and Builder
% tools, or simply to examine the calculations your trained neural
% network performs.
genFunction(net5,'myNeuralNetworkFunction');
y = myNeuralNetworkFunction(x);
end
if (false)
% Generate a matrix-only MATLAB function for neural network code
% generation with MATLAB Coder tools.
genFunction(net5,'myNeuralNetworkFunction','MatrixOnly','yes');
y = myNeuralNetworkFunction(x);
end
if (false)
% Generate a Simulink diagram for simulation or deployment with.
% Simulink Coder tools.
gensim(net5);
end
0 Commenti
Risposte (1)
Jayanti
il 2 Lug 2025
Hi,
The root cause of the issue appears to be incorrect assignment of multiple outputs due to repeated use of "y1(:,2)". Only two output columns are actually being passed to the network due to repeated overwriting of the same column index.
As a result, the model only receives "P_1" and "P_5". This can mislead the training process and result in poor performance.
Ensure that each output column is assigned to a unique column in the output matrix.Refer to the below code:
y1(:,1) = data.P_1;
y1(:,2) = data.P_2;
y1(:,3) = data.P_3;
y1(:,4) = data.P_4;
y1(:,5) = data.P_5;
This ensures that all five target outputs are passed properly to the neural network during training. Additionaly ensure the output variables vary over similar ranges to prevent biased training.
Hope this will be helpful!
0 Commenti
Vedere anche
Categorie
Scopri di più su Deep Learning Toolbox 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!