Degraph is a demonstrative differentiable programming project. The main idea is treating the plot of a graph as a differentiable function. The plot is associated with a loss function that represents the goodness of the plotting operation. The combination of differentiable representation (differentiable plot) and the loss opens the way to the application of an optimizer (eg. gradient descent) which can be used to optimize the "design". The implementation is based on Tensorflow 2.0 and Python 3.7.
The graphical representation of a graph is realized by plotting small discs on a 2D canvas for vertexes and Bezier curves of third degree for the edges. The positions of the vertexes and the control points of the edges (bezier) are the variables of the model. The optimization process starts with a graph where the vertexes and edges control points are initialized randomly, here is an example of the initial state and the result after the optimization is applied.
|Initial state||Final state|
Also an animation of the iteration of the optimizer (gradient descent) is available on youtube.
Internally the interactions between the various elements of the graph are represented by a differentiable raster (image),
specifically, radial basis functions are the core component of
the graphical entities.
The platform is highly customizable, specifically the components of the graph are represented as entities
(see entity.py) that can be connected in different configurations,
a simple example is available here.
Tensorboard is also supported, here is an example output.
Note the algorithm presented is not meant to compete with the state of the art algorithms for graph plotting, the sole purpose
is showcasing how differentiable programming can be applied to problems that are not "naturally" differentiable.
Subscribe to Python Awesome
Get the latest posts delivered right to your inbox