How can I avoid negative values in the output of a feedforward net?
Show older comments
Hello
I'm creating a neural feedforward net to predict hourly values of solar radiation. However, in some hours "at night" where it is supposed to generate a value of 0, a negative number is presented instead.
Output is a vector of 15 elements (one value each hour of the day) that vary from 0 to 1400.
Here is my code:
inputs = tonndata(xlsread('datosJP','inirr3'),false,false);
targets = tonndata(xlsread('datosJP','targirr3'),false,false);
net = feedforwardnet([12,8],'trainlm');
net.trainParam.lr = 0.05;
net.trainParam.mc = 0.1;
net.inputs{1}.processFcns = {'removeconstantrows','mapminmax'};
net.outputs{2}.processFcns = {'removeconstantrows','mapminmax'};
net.divideFcn = 'dividerand';
net.divideMode = 'time';
net.divideParam.trainRatio = 90/100;
net.divideParam.valRatio = 10/100;
net.divideParam.testRatio = 0/100;
net.performFcn = 'mse';
net = configure(net,inputs,targets);
a = 20*rand(12,size(x,2))-10;
net.IW{1} = a;
net = train(net,inputs,targets);
outputs = net(inputs);
errors = gsubtract(targets,outputs);
performance = perform(net,targets,outputs);
Accepted Answer
More Answers (0)
Categories
Find more on Define Shallow Neural Network Architectures in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!