How to using multi output in Neural network fitting app?

hi,
I want to develop a prediction model using Neural Network Fitting App in Matlab 2024a version.
I want to use two output data (A and B), but this app only produces one output.
Can't I use more than 2 outputs?

 Réponse acceptée

For your reference, the doc below explains how to create shallow neural networks with multiple outputs.
num_input = 1;
num_output1=2;
num_output2=1;
num_neuron=16;
NN=network;
NN.numInputs=1;
NN.numLayers=3;
NN.biasConnect(1:end)=1;
NN.inputConnect(1,1)=1;
NN.layerConnect=[0 0 0;1 0 0;1 0 0];
NN.outputConnect=[0 1 1];
NN.layers{1}.transferFcn='poslin';
NN.layers{1}.size=num_neuron;
NN.layers{2}.transferFcn='poslin';
NN.layers{2}.size=num_output1;
NN.layers{3}.transferFcn='poslin';
NN.layers{3}.size=num_output2;
NN.initFcn='initlay';
NN.inputs{1}.size=num_input;
NN.trainFcn='trainlm';
actual_input=rand(num_input,10);
actual_output1=rand(num_output1,10);
actual_output2=rand(num_output2,10);
NN_initialized=configure(NN,actual_input,{actual_output1; actual_output2});
% view(NN_initialized)
As a final note, I still would like to recommend you use Deep Network Designer for a more "intuitive" designing.

3 commentaires

지연 김
지연 김 le 4 Juin 2024
Modifié(e) : 지연 김 le 4 Juin 2024
Thank you :)
I am wondering how I can add a hidden layer to your code.
I wrote my code below. Can you tell me how to add hidden layer at your code or using multiple out at my code?
% Solve an Input-Output Fitting problem with a Neural Network
% Script generated by Neural Fitting app
% Created 01-Jun-2024 18:09:15
%
% This script assumes these variables are defined:
%
% Input_SI1 - input data.
% Output_SI1 - target data.
x = Input_SI1;
t = Output_SI1;
% Choose a Training Function
% For a list of all training functions type: help nntrain
% 'trainlm' is usually fastest.
% 'trainbr' takes longer but may be better for challenging problems.
% 'trainscg' uses less memory. Suitable in low memory situations.
trainFcn = 'trainlm'; % Levenberg-Marquardt backpropagation.
% Create a Fitting Network
hiddenLayerSize = 10;
net = fitnet(hiddenLayerSize,trainFcn);
% Setup Division of Data for Training, Validation, Testing
net.divideParam.trainRatio = 70/100;
net.divideParam.valRatio = 15/100;
net.divideParam.testRatio = 15/100;
% Train the Network
[net,tr] = train(net,x,t);
% Test the Network
y = net(x);
e = gsubtract(t,y);
performance = perform(net,t,y)
% View the Network
view(net)
% Plots
% Uncomment these lines to enable various plots.
%figure, plotperform(tr)
%figure, plottrainstate(tr)
%figure, ploterrhist(e)
%figure, plotregression(t,y)
%figure, plotfit(net,x,t)
funtion [y]=PCA_ANN(x)
PCA_ANN(Pred)
Well, my model already has one hidden layer with 16 neurons. What's between input layer and output layer can be thought of as hidden layers.
The code "num_neuron=16;" indicates a hidden layer?
How do we set the input and output datasets at your code?
(If the name of input dataset is input and that of output dataset are output1 and output2)
and Can I obtain each result of two output datasets?
Sorry, I used a neural network for the first time, so I don't know how I can use this.

Connectez-vous pour commenter.

Plus de réponses (0)

Produits

Version

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by