How to give multiple inputs to the train function of Neural Network?
55 次查看(过去 30 天)
显示 更早的评论
I am creating a neural network in MATLAB and am trying to feed it multiple inputs. How do I define the inputs and feed them into the network? If input 1 is some matrix of numbers and input 2 is another matrix of numbers, how do I correctly define both inputs? And then how do I feed them into the network?
For example, if I do "train(net,input,target)", then how do I send all of the inputs?
Also, how do I connect both the input blocks to the network?
采纳的回答
MathWorks Support Team
2017-9-1
Consider the following examples:
Given two inputs, x1 and x2 - You can create a cell array, x which can be then passed to the "train" function.
x1 = [4 5 6];
x2 = [0 1 0];
x = {x1;x2};
t = [0 0 1];
net = feedforwardnet;
net.numinputs = 2;
net = configure(net,x);
net = train(net,x,t);
view(net)
For both the input blocks to be connected to the neural network, there are multiple ways depending on the architecture you require:
You can connect the inputs to the network by altering the "inputConnect" property of the neural network as below:
x1 = [4 5 6];
x2 = [0 1 0];
x = {x1;x2};
t = [0 0 1];
net = feedforwardnet;
net.numinputs = 2;
net.inputConnect = [1 1; 0 0];
net = configure(net,x);
net = train(net,x,t);
view(net)
or
x1 = [4 5 6];
x2 = [0 1 0];
x = {x1;x2};
t = [0 0 1];
net = feedforwardnet;
net.numinputs = 2;
net.inputConnect = [1 0; 0 1];
net = configure(net,x);
net = train(net,x,t);
view(net)
0 个评论
更多回答(1 个)
Marcelo Olmedo
2020-5-6
Hello! Attached example taking data from a specific range in an Excel file. The key is in the input data composition. I hope it works. Cheers
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Modeling and Prediction with NARX and Time-Delay Networks 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!