MATLAB Answers

Neural Network - inverted pre-processing functions

1 view (last 30 days)
I know that using preprocessing functions have to transform the output of the neural network to their original values using:
P = inputs;
t = targets;
[pn, Mins, maxp, tn, mint, maxt] = premnmx (p, t);
net = train (net, pn, tn);
an = sim (net, pn);
postmnmx a = (an, mint, maxt);
I would like to know if using fitnet with new preprocessing functions integrated into the neural network ('mapminmax', 'processpca', 'mapstd') for the training and calculating the output of a new data set using:
newoutputs = net (newinputs);
I still have to convert and reconvert the new data or the transformation is performed automatically.
Is there any difference if I use:
new outputs = net (newinputs);
instead of:
newoutputs = sim (net, newinputs);
?
Thank you!

Accepted Answer

Greg Heath
Greg Heath on 25 Nov 2015
Edited: Greg Heath on 25 Nov 2015
Why are you wasting time on a question that you can answer yourself by simply running the example in
help fitnet
To better answer your problem add
max(abs(t-y))
Hope this helps.
Greg
  1 Comment
Emiliano Rosso
Emiliano Rosso on 25 Nov 2015
SOLVED
clear all
clearvars -global
inputs=[1,2,4,3,5;8,3,5,4,3];
targets=[1,0,0,1,1];
pnew=[1,4,3;1,6,5];
net=fitnet(1);
net.inputs{1}.processFcns = {};
net.outputs{2}.processFcns = {};
[pn,meanp,stdp,tn,meant,stdt] = prestd(inputs,targets);
net=train(net,pn,tn);
an = sim(net,pn);
output1 = poststd(an,meant,stdt);
pnewn = trastd(pnew,meanp,stdp);
anewn = sim(net,pnewn);
output1_new = poststd(anewn,meant,stdt);
my_weights = getx(net);
save('output1');
save('output1_new');
save('my_weights');
clear all
clearvars -global
load('output1','output1');
load('output1_new','output1_new');
load('my_weights','my_weights');
inputs=[1,2,4,3,5;8,3,5,4,3];
targets=[1,0,0,1,1];
pnew=[1,4,3;1,6,5];
net=fitnet(1);
net.inputs{1}.processFcns = {};
net.outputs{2}.processFcns = {};
net.inputs{1}.processFcns = {'mapstd'};
net.outputs{2}.processFcns = {'mapstd'};
net=train(net,inputs,targets);
net = setx(net,my_weights);
output2=net(inputs);
output2_new=net(pnew);
save('output2');
save('output2_new');
clear all;
clearvars -global;
load('output1','output1');
load('output1_new','output1_new');
load('my_weights','my_weights');
load('output2','output2');
load('output2_new','output2_new');
if isequal(output1,output2)==1
disp('output1 is equal to output2');
else
disp('output1 is NOT equal to output2');
end
if isequal(output1_new,output2_new)==1
disp('output1_new is equal to output2_new');
else
disp('output1_new is NOT equal to output2_new');
end
COMMAND WINDOW:
output1 is equal to output2
output1_new is equal to output2_new
getx & setx are used to use the same training.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!