MATLAB Answers

data and nn input sizes do not match..

4 views (last 30 days)
SShamtej Singh Rana
SShamtej Singh Rana on 25 Jul 2019
my neural network is supposed to take an coloumn vector input [7x1] and output a value 1-3 that refers to a certain condition.
the way i have these set up is below, as well as a copy of the network code.
when i try to run this, i get an error "the numbers of input signals and networks inputs do not match"
this happens when i try to use net=configure(net, input), using my dataset.
im new to matlab so let me know if the mistake is just somewhere simple, ill have trouble finding it...
data= {temp;humid;SLP;precip;SWR;wind;dir};
%make a variable that treats all our coloumns as a matrix. i put this here
%and used it below to try and make the code work but it is making a 7 x 1
%cell instead of a 7x38000 matrix of all my input sets.
predictionNet.numInputs= 7;
predictionNet.numLayers= 5;
%first three lines are just initialization of the predictionNetwork.
%select which layers we want biases for
predictionNet.inputConnect=[1 1 1 1 1 1 0
0 0 0 0 0 0 1
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0];
%boolean matrix of T/F connections between inputs and weights
predictionNet.outputConnect=[0 0 0 0 1];
%select which layers will connect to the final output
predictionNet.layerConnect=[0 0 0 0 0
1 0 0 0 0
0 1 0 0 0
0 0 1 0 0
0 0 0 1 0];
%outlines which layer you want to feed into a current layer out of all
%set number of neurons in each layer. the last layer has to be size 1 to
%get an indication of warning/fire/safe
predictionNet.layers{2}.transferFcn = 'logsig';
predictionNet.layers{2}.initFcn = 'initnw';
predictionNet.layers{3}.transferFcn = 'logsig';
predictionNet.layers{3}.initFcn = 'initnw';
predictionNet.layers{4}.transferFcn = 'logsig';
predictionNet.layers{4}.initFcn = 'initnw';
predictionNet.layers{5}.transferFcn = 'logsig';
predictionNet.layers{5}.initFcn = 'initnw';
%set the transfer function and the initial functions.
%i chose tansig for the first so everything is centered around a mean, and
%then I chose logsig so everything is more probabalistic.
predictionNet.initFcn= 'initlay';
%divides training data randomly
%choosing which plots i want when the data is read.
predictionNet= train(predictionNet, data, output);


Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by