Neural Network Input Size and Data Issue - HELP
显示 更早的评论
Hi,
I am trying to code a feed forward neural network to predict future significant wave heights given known previous wave height values.
I have two inputs to my network. These are the wave heights over a year for two weather buoys. One input for my network is the wave heights over a year for one weather buoy (8744 data values), and the other input is the wave height values over one year for the second buoy (again 8744 data values).
I am coming up with the error 'Number of inputs does not match net.numInputs.' Can someone help spot my mistake please?
I am not sure what value I should be using in 'net.inputs{1}.size'.
My code is as follows:
%Data Selection
X = xlsread('2014_comp.xlsx', 'F5:F8748');
Y = xlsread('2014_comp.xlsx', 'L5:L8748');
%Network Architecture
net = feedforwardnet; % create feed forward network
net.numInputs = 2; % set number of inputs
net.inputs{1}.size = 1; % set size of input 1
net.inputs{2}.size = 1; % set size of input 2
net.numLayers = 1; % add 1 layer to network
net.layers{1}.size = 10; % assign number of neurons in layer
net.inputConnect(1) = 1; % connect input 1 to layer 1
net.inputConnect(2) = 1; % connect input 2 to layer 1
net.biasConnect(1) = 1; % connect bias to layer 1
net.biases{1}.learnFcn = 'learnp'; % set bias learning function
net.biases{1}.initFcn = 'initzero'; % set bias init function
net.outputConnect(1) = 1; %connect layer 1 to output
net.layers{1}.transferFcn = 'tansig'; % set layer transfer function to hyperbolic tangent sigmoid
net.inputWeights{1}.initFcn = 'initzero'; % set input wieghts init function
net.inputWeights{1}.learnFcn = 'learnp'; % set input weight learning function
net.initFcn = 'initlay'; % set network init function
net.trainFcn = 'trainrp'; % set network training function
net.performFcn = 'mse'; % set network performance evaluation function
%Training/Testing/Validation Ratio
net.divideParam.trainRatio = 0.66; % set proportion of data for training
net.divideParam.valRatio = 0.17; % set proportion of data for validation
net.divideParam.testRatio = 0.17; % set proportion of data for testing
view(net)
%Network Training
net = train(net,X); %Train the network
Thanks, James
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Sequence and Numeric Feature Data Workflows 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!