Is there any way to draw a neural network's connections in a nice way?



I've been working with neural networks and artificial intelligence for a while. What I'm trying to do right now is, from a genotype I have (a sum of sensors, neurons and actuators) draw how the neural network is (with recurrent/recursive connections being showed nicely, etc.)

What I have done now in javascript is this:

I know, its ugly

I have achieved this using SigmaJs, a Javascript drawing library, but I think it's still ugly, and what I'm looking for is a node drawing library that can achieve recursive connections in a nice way (right now, I'm drawing them with a red color as you can see on the image).

I have examined a lot of GitHub repositories and websites that can be helpful but aren't worth it since they aren't that nice.

Has anyone got an idea of what can I use, in javascript? If not, in any other language, how can I achieve what I want?


Posted 2017-06-12T20:48:17.710

Reputation: 53

Question was closed 2020-05-22T18:15:24.170



I'm the developer of Neataptic, a Javascript neural network library. I don't know if it is exactly what you're looking for, but it has a built-in graph creator using D3 and webcola.

Basically, each connection gets an arrow. It also supports self-connections and gates.

There are some examples of images:

Play around yourself here.

Thomas W

Posted 2017-06-12T20:48:17.710

Reputation: 967

1Hey Thomas, any idea if it is possible to modify the drawGraph function to use canvas instead of svg (performance issues) in an easy way? – MiGu3X – 2017-06-15T23:09:11.313

1@MiGu3X i'm sorry, I don't know. I never really experimented with it too much – Thomas W – 2017-06-16T09:55:30.570


You might have come across the Tensorflow Playground which has a wonderful visualization of the network connections and the neuron weights.

Their code is available in GitHub (here), and the code seems fairly simple. It is coded in typescript but that can be easily transpiled to pure JavaScript.


Posted 2017-06-12T20:48:17.710

Reputation: 361