  Thanks to their ease of implementation, multilayer perceptrons (MLPs) have
become ubiquitous in deep learning applications. The graph underlying an MLP is
indeed multipartite, i.e. each layer of neurons only connects to neurons
belonging to the adjacent layer. In contrast, in vivo brain connectomes at the
level of individual synapses suggest that biological neuronal networks are
characterized by scale-free degree distributions or exponentially truncated
power law strength distributions, hinting at potentially novel avenues for the
exploitation of evolution-derived neuronal networks. In this paper, we present
``4Ward'', a method and Python library capable of generating flexible and
efficient neural networks (NNs) from arbitrarily complex directed acyclic
graphs. 4Ward is inspired by layering algorithms drawn from the graph drawing
discipline to implement efficient forward passes, and provides significant time
gains in computational experiments with various Erd\H{o}s-R\'enyi graphs. 4Ward
not only overcomes the sequential nature of the learning matrix method, by
parallelizing the computation of activations, but also addresses the
scalability issues encountered in the current state-of-the-art and provides the
designer with freedom to customize weight initialization and activation
functions. Our algorithm can be of aid for any investigator seeking to exploit
complex topologies in a NN design framework at the microscale.
