Neural Learning with Tensorflow2.0 Part-3 ( Tensorflow Model Graph in Neo4j and Linkurious)
In Part-2 of Neural Learning, we built a simple model for computing sum of two numbers.
In this part we will using Neo4j and Linkurious (a graph visualization tool) view the computational graph that we have trained.
A computational graph is a way to represent a math function in the language of graph theory.In such computational graph nodes are either input values or functions for combining values. Edges receive their weights as the data flows through the graph
With tensorflow Keras api's we can easily extract the variables, weights, bias, activation functions used etc.. in model. The structure of model we built in previous part looks like
Once a model is well trained, extract weights and biases that were updated on each neuron with gradient descent and load them in neo4j.
Once these are loaded in neo4j, graph looks like,
'HAS_NEXT' is a relation between successive layers of nodes. Each node has bias as property and relationship holds 'weight' property.
Lets view the graph in Linkurious and try to get some insights.
Tensorflow graph in Linkurious
Using Linkurious we can quickly explore the components (weights on edges and biases on nodes). As complexity of graph increases like in each layer if there are number of neurons, to extract information from such graphs becomes easier. Using this visualization tool, we can easily answer some questions like, How the distribution of weights between layers look like ? Are there positive or negative weights in each layer ? How many nodes have 0 bias or undefined bias ? etc
Let's keep some styles to the Linkurious graph.
With the above graph we can easily distinguish negative weights(grey colored) and nodes with 0 biases (red colored) and edges that have highest weight (orange colored).
We can also represent what activation function was applied on each neuron. And what the effect of weights and biases happened due to those activation functions.
Let's see how a more complex network looks like in Linkurious
We can click on each node and check for bias and weight over edges. This is one way visualizing a tensorflow model.
Thanks for reading !!