Need help with multiple input in ANN

조회 수: 17 (최근 30일)
Mohamad
Mohamad 2022년 11월 20일
답변: Tejas 2024년 11월 29일
HI there,
I have a project which is related to water networks and I want to train ANN to predict based on that.
Here's my project in simple words: for example, I have 3 nodes and 5 pipes. I created traning data for ANN (for example, 4 scenarios) and the attribute of pipes (roughness and diametere) are constant in all scenarios. And my target is pressure in some nodes not all of them in all scenarios.
I worked with ANN before with only one input and one output and it worked fine. I don't know how to get answer with multiple inputs with different in size. I'm not sure whether ANN can solve this problem or not but it is very similar to my previous project (simple input and output).
This is the code I'm trying to work on but I get error and I don't know how to fix it:
a=[4 5 6; 5 5 8; 8 9 2; 8 9 6 ] %demands (3 nodes and 4 scenarios)
b=[8 9 5 8 1] %roughness (5 pipes constant in all scenarios)
c=[7 7 7 0 4] %diameter (5 pipes constant in all scenarios)
inputData={a;b;c};
target = [0 1; 5 1; 7 2; 5 1]; %pressure (2 pressure nodes and 4 scenarios)
net = feedforwardnet;
net.numinputs = 3;
net.inputConnect = [1 1 1; 0 0 0];
net = configure(net,inputData);
net = train(net,inputData,target);
view(net)
Please help me to figure it out or if ANN is not able to solve these kind of problems, help me out to find something else
In the end, I want to use the trained ANN to predict pipe attributes (roughness and diameteres) with different demands and pressures.
Thank you in advance!

답변 (1개)

Tejas
Tejas 2024년 11월 29일
Hello Mohamad,
To predict pipe attributes, roughness and diameter, using demand and pressure as inputs, follow these steps:
  • Define the input data as illustrated in the code snippet below.
demands = [4 5 6; 5 5 8; 8 9 2; 8 9 6];
pressures = [0 1; 5 1; 7 2; 5 1];
inputData = [demands pressures];
  • Define the target data as shown in the subsequent code snippet.
roughness = repmat([8 9 5 8 1], 4, 1);
diameter = repmat([7 7 7 0 4], 4, 1);
targetData = [roughness diameter];
  • Set up and train a 'feedforwardnet' neural network with 10 hidden neurons.
net = feedforwardnet(10);
net = configure(net, inputData', targetData');
[net, tr] = train(net, inputData', targetData');
After training the model, the following code snippet can be used to predict the pipe attributes:
newDemands = [5 5 5];
newPressures = [1 2];
newInput = [newDemands newPressures];
predictedAttributes = net(newInput');

카테고리

Help CenterFile Exchange에서 Deep Learning Toolbox에 대해 자세히 알아보기

태그

제품


릴리스

R2016a

Community Treasure Hunt

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

Start Hunting!

Translated by