Neuroph is an awesome java neural network framework for machine learning. While I use the framework’s API, it also provides a graphical user interphase which allows visualization of neural networks. Unfortunately, the visualization fails for networks with a large number of nodes. Here I introduce a GraphML export functionality for Neuroph allowing visualization in Gephi.
In my work I use neural networks with several hundred input and hidden nodes. I would like to use interactive visualization and some graph theory algorithms to perform exploratory analysis. For such analyses I normally use Gephi and the R package iGraph, respectively. Both of these tools can import network architectures saved in the GraphML format, which uses XML syntax to describe structural properties of graphs.
I contributed a package to the Neuroph project neuroph.contrib.graphml, which allows export of a trained neural network as a GraphML file, specifying network topology as well as node-labels and learned weights. Export is performed with a few lines of code as shown in Example.java:
// Generate an example trained network.
NeuralNetwork ann = ExampleNetworXOR.getNetwork();
// Export to file
GraphmlExport ge = new GraphmlExport( ann ); // Instantiate a GraphmlExport object with a trained network.
ge.parse(); // Parse the NeuralNetwork to GraphML representation.
ge.writeToFile( "/FILE/PATH/OUT" ); //Write GraphML to file.
Visualization of the exported network allows easy identification of important network nodes. Let's define important nodes as those with edges with large absolute weight. The GraphML is imported into Gephi, the network visualized in a space-filling way and edges colored by weight:
While this visualization is aesthetically appealing, the edges with large weight are difficult to spot due to the number of edges. This is where the interactive potential of Gephi comes into play. We can selectively show edges with large positive weight (left) or large negative weight (right):
We can thus easily identify nodes with high contributing potential. While this example just shows the start of an exploratory analysis, I hope it demonstrates how quick and interactive the GraphML export functionality for Neuroph can make it.