Negative output neural networks

D
david_s · Jul 16, 2021 · 1.9K views
Question
I trained my neural network, but it generates negative values even though the target values are positive. I wonder why ?  
Expert Answer
Profile picture of John Williams
John Williams PhD Expert
Answered Nov 20, 2025
the output of the neural network depends on the transfer function of the output layer, if the results are negative you probably have a transfer function like "tansig" or "purelin", I recommend that if you don't want negative values you should change the transfer function, if the answer is in the range from 0 to 1 you can change it to "logsig" or whatever function you desire :
 
 
net.Layers{end}.transferFcn='logsig';
100% Run Guarantee 3-Hour Fast-Track Delivery

Need a Custom Version or Complete Simulation for This Problem?

Our 500+ PhD engineers build, debug, and optimize working MATLAB scripts and Simulink (.slx) models tailored to your exact assignment rubrics with zero plagiarism.

Tested on MATLAB R2024b / R2026a
Turnitin 0% Plagiarism Report
Free 7-Day Revisions Guarantee
Have a different question? Ask here

Get a Free Consultation or a Sample Assignment Review!