How can I plot a neural network?

70 views (last 30 days)
Say I created a neural network, such as net = feedforwardnet(30);, which I trained [net tr] = train(net,p,t);
How can I plot this neural network? I would like something like:
(I'm especially interested in having the weights displayed on the graph)
Thanks, Franck

Accepted Answer

Greg Heath
Greg Heath on 23 Jan 2013
The only NNTBX display that is available is
However, perhaps you can find something online.
Hope this helps.
Thank you for accepting my answer.
  1 Comment
Franck Dernoncourt
Franck Dernoncourt on 23 Jan 2013
Thanks for your answer, view() was indeed the only function I could find… But I'm surprised there is no existing code for such a common task. Maybe some function to output the network to a .dot file that we would give to GraphViz?

Sign in to comment.

More Answers (2)

Yashwant Kolluru
Yashwant Kolluru on 12 Jul 2018
[a,b] = train(net,x,t); y = net(x); e = gsubtract(t,y); %%%%%%%%%%%%%%%%%%% figure, plotperform(b); figure, plottrainstate(b); figure, ploterrhist(e); figure, plotregression(t,y);
hope it helps

fred  ssemwogerere
fred ssemwogerere on 2 Jan 2020
Hello, with the latest Matlab version 2019b, you are availed with a wide range of functions that can do this job for you. With my program for neural network modeling, i added some lines of code that also plot the best neural network. You can start by checking out the "line" and "viscircles" functions in the Matlab documentation. These can help you with what you want to plot. Below is a sample plot output from my code, of the best network i was designing. With added work, you can modify the lines to visualize the magnitude and direction of the weights, remove the axis bars, and many other things that you would like to do.
  1 Comment
Maha Mosalam
Maha Mosalam on 1 Mar 2021
can you submit the line codes to do this, please

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!