Writing code using the data flow graph as an architectural roadmap
TensorFlow is a graph-driven solution based on graph theory, a branch of mathematics. Designing deep learning without graphs would prove quite difficult. My XOR FNN built from scratch in Chapter 4, Become an Unconventional Innovator, fits the need of the case study described. However, if thousands of nodes are required, TensorFlow, Keras (with TensorFlow backend), or other similar solutions will be needed. In this chapter, a neural network will be developed in TensorFlow.
The building blocks of graphs are nodes (or vertices, or points) and edges (or lines) that connect the nodes to one another.
In TensorFlow parlance, nodes are cleverly named ops for operations. In Chapter 4, Become an Unconventional Innovator, the Python example shows exactly that: nodes as operations and calculations.
Mathematical models will be described through a data flow graph. The first step is to build the model, your architecture.
In a TensorFlow program, the first top source code lines are not just a new way to describe variables that you will use later. They are the program. They are critical to the computation of the graph. In fact, TensorFlow uses the graph to compute the operations. The graph is the architecture, the roadmap that describes the whole computation process of a deep learning neural network. The following graph has taken the code lines and transformed them into a graph. Imagine that the following graph is a network of water pipes in the city. First, the city builds the pipes. Only then does the water (data in our case) flow in those pipes. The pipes (TensorFlow variables, arrays, and other objects) are not a formality. They represent the core architecture of a system.
This graph is built with FNN_XOR_Tensorflow_graph_only.py to show how to use TensorBoard to analyze your network. It will prove easier to fix design errors with TensorBoard. Click on the nodes to explore the details of each part of the graph. Run the program; then run TensorBoard_reader.py to launch TensorBoard.
The following diagram illustrates this:
A dataflow graph