MATLAB: Input to a custom network

input to custom networkneural networkstraining of the custom network

I am designing a neural network with 4 inputs and 2 layers including the output layer. the input database is in an excel document and is of the matrix which has 97rows and 5 columns. This is in one sheet and I have 11 such sheets. I am able to import the data to the M-file; however I am unable to give it as an input to the neural network to train. How am I supposed to give my database as the input? Also using trainlm, it gives me an error saying zero input delay. How am I supposed to use the train function [net tr] if my and the input database is all those 11 sheets and the target is just one column?

Best Answer

% Read in the 11 sheets and combine to obtain a data matrix with size(data) = [ 5 1067 ] (1067 = 11*97)
close all, clear all, clc
input = data(1:4,:);
target = data(5,:);
[ I N ] = size(input) % [ 4 1067 ]
[ O N ] = size(target) % [ 1 1067 ]
% I = 4
% O = 1
% N = 1067
% input = randn( I ,N );
% hidden= sum(input);
% target = 1 + hidden+ hidden.^2 ;
% plot(hidden,target,'o')
% Using the NN default data division
Ntrn = N - 2*round(0.15*N) % 747
Neq = Ntrn*O % 747 Number of training equations
% Assuming an I-H-O = 4-H-1 FFMLP for regression or curvefitting, the number of unknown weights to be estimated by the 747 equations is
% Nw = (I+1)*H+(H+1)*O = O+(I+O+1)*H = 1+6*H.
% Typically, Neq > Nw is required although Neq >> Nw is desired. The resulting upper bound on H is
Hub = floor((Neq-O)/(I+O+1)) % 124
% Therefore, the default value H = 10 << Hub = 124 is a reasonable first choice.
net = fitnet;
net.trainParam.goal = var(target)/100;
[net tr Y E ] = train(net,input,target);
Hope this helps.
Greg