MATLAB: Processing of i/p data

data processingDeep Learning Toolboxfeedforwardfeedforwardnetmapminmaxneural networknewff

do i have to normazile input data before introducing them to the network????…..i've read in nn toolbox that by default network normalizes inputdata so that they would fall in range of -1& 1 before starting to process them. but when i introduced data direclty without any normalization i got different results than those when i introduced data to the network after i normalized them !!! which one gives the correct data ??? do i have to normalization data before introducing them to the network ???isnot default processing of data done by the network itself is enough???

Best Answer

Hi Hoda,
It is generally considered a good practice to pre and post process the data before and after its handled by the network. And that is what the NN toolbox does by default.
The available methods for pre processing inputs and post processing outputs can be access in a 2-layer network by typing:
net.inputs{1}.processFcns
net.outputs{2}.processFcns
So, you won't have to do anything at all. The network will receive your inputs and normalize them using mapminmax. Then the data will be processed by the network and then the outputs will be transformed back to your original units.
An example to make the math more clear:
load cancer_dataset;
% Creating a 2-layer Feed-forward network
mlp_net = newff(cancerInputs,cancerTargets,2,{'tansig'},'trainlm');
% Training the network
[mlp_net,tr] = train(mlp_net,cancerInputs,cancerTargets);
% New input to be simulated
p = 10*rand(9,1);
% The network is using mapminmax under the hood
y0 = sim(mlp_net,p);
% Now, let's do it manually to see if we obtain the same results:
p2 = mapminmax('apply',p,mlp_net.inputs{1}.processSettings{3});
y1 = purelin(mlp_net.lw{2,1}*tansig(mlp_net.iw{1,1}*p2+mlp_net.b{1,1})+mlp_net.b{2,1});
y2 = mapminmax('reverse',y1,mlp_net.outputs{2}.processSettings{2});
>> isequal(y0,y2)
ans =
1
Again, if you are using MATLAB R2011a, feedforwardnet is more efficient than newff. Just wanted to make sure that you can run the code no matter what version you have.