0
votes

This is my code:

p = input1;
t1 = output1;
net = feedforwardnet(10, 'trainrp');
net.trainParam.epochs = 1000;
net.trainParam.goal = 0.0005;
net = train(net, p, t1); 
y1 = sim(net, p);
p = input2;
t2 = tar;
y2 = sim(net, p);

However, I get this error:

error using bsxfun
Non-singleton dimensions of the two input arrays must match each other.

Error in nnMATLAB.pc (line 24)
pi = bsxfun(@minus,pi,settings.xoffset);

Error in nncalc.preCalcData (line 20)
data.Pc = calcMode.pc(net,data.X,data.Xi,data.Q,data.TS,calcHints);

Error in nncalc.setup1 (line 118)
calcData =

nncalc.preCalcData(matlabMode,matlabHints,net,data,doPc,doPd,calcHints.doFlattenTime);

Error in network/sim (line 283)
[calcMode,calcNet,calcData,calcHints,~,resourceText] = nncalc.setup1(calcMode,net,data);

I want to make a neural network which has input1 as input 310 x 24 matrix and output1 as output, 155 x 24 matrix.

Also, I will train the network with input1 & output1

After this training process, I will use input2 as testing data, and I want to get a simulation result using above network which is trained by input1 & output1 .

In summary, I want to train my own network with input1 and output1, and I want to get my simulation result with input2.

I think these errors are based on input size difference between training section and testing section.

How can I solve this problem? Should I run additional process??

I'm looking for your kind answer.

Thank you.

1

1 Answers

0
votes

The number of inputs for training and testing must be the same.

For training: inputs must be an NxQ matrix where N is the number of input elements and M is the number of samples. Target must be an MxQ matrix where M is the number of output elements and Q is the same as for inputs.

Then for testing: the input matrix must be NxQ2, where N is the same as for training, but the number of samples Q2 can be whatever you want. For instance, for a single vector Q2 equals 1. The output will then be MxQ2 where M is the same as the number of outputs used for training and Q2 is the same number of vectors as the test input data.