Learning Graph Cellular Automata

1 Introduction . Cellular automata ( CA ) [ 1 ] are discrete computational models that consist of a regular lattice of cells , each associated with a state , and a transition rule . The transition rule is usually defined to update the state of each cell as a function of its current state and the state of its neighbours . Even when using simple transition rules and low-dimensional lattices , CA can exhibit very intricate patterns that emerge from the repeated synchronous application of the transition rule . Despite being almost a century-old idea , many different forms of CA are still studied today in dynamical systems theory [ 2 ] . In this paper , we focus on a generalised version of CA called graph cellular automata ( GCA ) [ 3 ] , which relaxes the assumption of the lattice structure and allows cells to have an arbitrary and variable number of neighbours . Starting from the observation that GCA are a generalised version of lattice-based CA , in which the underlying lattice is replaced by an arbitrary graph , we focus on the analogous parallel that exists between convolutional neural networks ( CNNs ) and graph neural networks ( GNNs ) [ 4 , 5 , 6 ] . Namely , the goal of this paper is to study the application of GNNs to learn a desired GCA transition rule , a setting that we refer to as Graph Neural Cellular Automata ( GNCA ) . The inspiration for this work comes from a recent series of papers that studied how to train a convolutional neural network to approximate a desired CA transition rule , which we extend in two significant ways . First , we present a general-purpose architecture for GNCA and show that it is sufficient to represent any arbitrary GCA with finite and discrete state space . Based on well-known results on the expressive power of neural networks and GNNs , we also propose that the same architecture is expressive enough to represent any transition function on continuous state spaces . Then , we present several classes of problems that can be formulated as computation with GCA . We use our architecture to learn a varied family of GCA with non-trivial features including discrete and continuous state spaces , complex or unknown transition rules , dynamic graphs , and the ability to globally coordinate through local message exchanges . First , we train a GNCA to approximate a GCA defined on the Voronoi tessellation of random points , where the underlying graph is fixed throughout the evolution of the system and the state space is binary . Then , we focus on a dynamic GCA with 35th Conference on Neural Information Processing Systems ( NeurIPS 2021 ) . continuous state space and variable connectivity between cells . We consider the Boids algorithm [ 7 ] , a Markovian and distributed multi-agent system designed to simulate the flocking of birds , and we train the GNCA to reproduce its behaviour . Finally , we consider the task of learning GNCA that converge to a target state in a continuous state space . Specifically , we train the GNCA to reconstruct the coordinates of a geometric point cloud . The practical implications of this work are evident when considering that distributed systems are 1 ) the norm in nature , where complex behaviour is observed as an emergent property of simple and distributed computation , and 2 ) ubiquitous in technology , with the advent of cyber-physical systems that need to operate and react to local events while coordinating to achieve a target behaviour ( for example , self-driving cars that act locally to avoid crashes but must prevent traffic globally ) . By applying GNNs to model GCA on systems described by graphs , we enable the discovery of unknown rules that allow us to solve tasks through emergent and distributed computation . 2 Related works . This work extends the results of many foundational works on learning CA with neural networks , which so far have only focused on regular lattices . A seminal work on the subject is that of Wulff and Hertz [ 8 ] , who successfully trained a small neural network ( NN ) to imitate 1D and 2D binary CA with chaotic or complex dynamics . A subsequent approach is that of Elmenreich and Fehérvári [ 9 ] , who designed an evolutionary algorithm to identify a NN transition rule that would generate a desired pattern ( a process called morphogenesis ) . Similarly , Nichele et al . [ 10 ] used the NEAT genetic algorithm [ 11 ] and compositional pattern producing NNs [ 12 ] for morphogenesis and pattern replication in a CA with discrete states . Recently , Gilpin [ 13 ] showed how to implement any CA transition rule using the receptive field of a CNN , as well as showing that arbitrary binary rules can be learned end-to-end with gradient descent . In a follow-up analysis , Springer and Kenyon [ 14 ] observed that CNNs often fail to converge to exact solutions when trained to reproduce the Game of Life ruleset and that they often require many more parameters than the minimal number necessary to implement the exact transition rule , as predicted by the lottery ticket hypothesis [ 15 ] . The idea of learning 2D CA transition rules was also explored by Aach et al . [ 16 ] , who proposed an encoder-decoder architecture with the ability to generalise to unseen neighbourhood configurations and sizes . Mordvintsev et al . [ 17 ] recently introduced Neural Cellular Automata ( NCA ) . The idea of NCA is to use a CNN to learn the transition rule of a 2D CA with a continuous and multi-dimensional state space , which they interpret as an image . In particular , they trained the NCA to converge to a specific image . They showed that , with proper training , NCA could reconstruct missing patches of the target image and were resilient to many classes of state perturbations . Randazzo et al . [ 18 ] also showed that NCA can be used to classify MNIST digits . This is an example of local behaviour leading to a global agreement about the overall structure of the system . Since a CNN can be interpreted as a particular case of a GNN with fixed-size neighbourhood and anisotropic filters , what we propose here is a general extension of the works mentioned above . 3 Method . 3.1 Graph Cellular Automata . A GCA is a 4-tuple ( G , S , N , τ ) where G = ( V , E ) is a graph with node set V ( |V | = n ) and edge set E ∈ V × V , S is the state set , N : V → 2V is the neighbourhood function s.t . N ( i ) = { j | ( j , i ) ∈ E } , and τ is a local transition rule . Let si ∈ S indicate the state of node i . The transition rule is then defined as τ ( si ) : { si } ∪ { sj | j ∈ N ( i ) } 7→ s′i . ( 1 ) For brevity , we denote with S ∈ Sn the state configuration for the entire automaton and we write S′ = τ ( S ) to indicate the synchronous application of τ to all cells . The original CA formalism allows for transition rules that can treat the different neighbours of a cell differently , according to their position with respect to the cell . This idea is , for instance , at the base of the Wolfram code for enumerating CA transition rules [ 19 ] . In GCA a similar anisotropic behaviour can be obtained by uniquely enumerating the neighbours of each cell and adapting the transition rule accordingly . More generally , we can assign to each edge ( i , j ) ∈ E an attribute eij ∈ Rde encoding , for example , the direction , distance , or unique identification of node i relative to node j . It is also possible to consider any arbitrary attributes associated with edges , representing abstract relations between any two neighbouring cells . In short , we can see anisotropy in GCA as a dependence of the transition rule on the specific relation that exists between a cell and a neighbour : τ ( si ) : { si } ∪ { sj , eji | j ∈ N ( i ) } 7→ s′i . ( 2 ) The usefulness of this definition will become evident in later sections . 3.2 Graph Neural Networks . Graph Neural Networks ( GNNs ) are a family of models designed to process graph-structured data . The core functionality of many GNNs can be described with a message-passing scheme . Let hi ∈ Rdh represent a vector attribute associated with the ith node of a graph and eij ∈ Rde an edge attribute as defined above . A message-passing GNN is a function that computes a vector h′i ∈ Rd ′ h according to the following scheme : h′i = γ ( hi , j∈N ( i ) φ ( hi , hj , eji ) ) , ( 3 ) where φ is the message function , is a permutation-invariant operation to aggregate the set of incoming messages , and γ is the update function . When φ , , and γ are differentiable operations , message-passing layers can be stacked and their parameters can be learned end-to-end with backpropagation and stochastic gradient descent . In this work , specifically , we adopt a message-passing architecture inspired by You et al . [ 20 ] s.t . h′i = hi ∥∥∥ ∑ j∈N ( i ) ReLU ( Whj + b ) , ( 4 ) where ‖ indicates vector concatenation , ReLU is the Rectified Linear Unit activation , and W ∈ Rd′h×dh and b ∈ Rd′h are trainable parameters . The message-passing block is also preceded and followed by multi-layer perceptrons ( MLPs ) with ReLU activations , whose task is to learn nonrelational transformations of the node features [ 20 ] . The architecture is schematically shown in Fig . 1a . Note that Eq . ( 4 ) can easily be extended to account for edge attributes as well , although we will see in later sections that different use cases may benefit from different ways of incorporating that information . We mention two main techniques to achieve this kind of anisotropy , both based on making the message function φ edge-dependent : 1 ) the weights matrix W can be computed as a function of eji , through a kernel generating network [ 21 ] , and 2 ) eji can be concatenated to hj to compute the messages . 3.3 Graph Neural Cellular Automata . The goal of this paper is to explore the parallel that exists between GCA and GNNs . In particular , here we consider a setting in which the state transition function of a generic GCA is implemented with a GNN , which we indicate as a Graph Neural Cellular Automaton ( GNCA ) . The relation between the two models can be immediately seen by comparing Eqs . ( 2 ) and ( 3 ) , as the GNN model contains all the necessary elements to describe a GCA transition rule . First , when the GNN is configured so that dh = d′h , then both functions are endomorphisms that depend only on node i and its neighbourhood N ( i ) . Then , by considering S ≡ Rdh , the state of the GCA can be interpreted as a graph signal s.t . hi = si . Finally , as previously mentioned , the GNN can be configured to take into account edge attributes , allowing it to model transition rules that can be both isotropic or anisotropic . We also note that CA rules with larger neighbourhoods ( e.g. , the Lenia CA [ 22 ] ) can be implemented by our GNCA by stacking multiple message-passing layers or by re-defining the neighbourhood function to include higher-order neighbours . This will be explored in future work . We indicate with τ ( S ) the transition function of a GCA and with τθ ( S ) the transition function of a GNCA with learnable parameters θ . The dependency of either function on graph G is left implicit . Finally , we use d to indicate the states ’ dimension . The specific GNN architecture of τθ that we consider in Eq . ( 4 ) , besides being motivated by the results of You et al . [ 20 ] , has a sufficiently high number of parameters which , as noted by Springer and Kenyon [ 14 ] , can be a deciding factor for learning the transition rule of a CA . This requirement is also somewhat reflected by the architectural choices of Mordvintsev et al . [ 17 ] . Implementing GCA with M -state space One of the main results of Gilpin [ 13 ] was to show different ways to implement an arbitrary M -state CA with a CNN . The most straightforward implementation proposed by the author relied on two main neural computation blocks : 1 . Two convolutional layers with 1x1 filters , to compute a one-hot encoding of the states ; 2 . One convolutional layer with 3x3 filters , to match all of the possible input patterns of the transition rule and compute the corresponding output . The general principle used to design the transition rule of a CA with a CNN can be straightforwardly extended to GCA and GNNs . Consider a GCA with state space S = { 1 , ... , M } and n cells , with maximum node degree dmax ≤ n ( and , usually , dmax n ) . The first block of Gilpin ’ s implementation remains the same , since it is a transformation applied individually to each node , independently of its neighbours . The second block requires us to be more careful . First , we note that Gilpin ’ s implementation covers the most general case in which the transition rule is anisotropic . By generalising this principle to the case of GCA , as discussed in Sec . 3.1 , we require that each cell has up to dmax neighbours identified by a unique one-hot vector edge attribute . The pattern matching mechanism proposed by Gilpin can then be implemented with a bank of dmax weight matrices of shape M ×Mdmax , that is used to compute the message from each neighbour , according to its associated edge attribute ( e.g. , consider the work of Simonovsky and Komodakis [ 21 ] ) . We note , however , that this case represents an upper bound in complexity , since many GCA rely on isotropic rules and better implementations can be obtained if the structure of the GCA rule is known . For example , Conway ’ s Game of Life can be implemented with a CNN consisting of one convolutional layer with 3x3x5 filters , with one channel to implement the identity and four channels to count neighbours , and two convolutional layers with 1x1x5 filters for pattern-matching [ 13 ] . We note that the GNCA covers this result as it natively implements the identity ( the concatenation of Eq . ( 4 ) can be replaced with a sum to match the exact implementation ) and neighbour counting can be achieved with W = [ 1 , 1 , 1 , 1 ] and b = [ −1 , −2 , −3 , −4 ] ( cf . [ 13 , Appendix A ] ) . Finally , the 1x1x5 convolutional layers are equivalent to the post-processing dense layers described in Sec . 3.2 . In Sec . 4.1 , we will see a similar minimal implementation for an outer-totalistic GCA . Extension to continuous state space We can also conjecture that the architecture described in Sec . 3.2 is expressive enough to represent any transition function for a GCA with continuous state space . First , it is a well-known result of machine learning theory that a two-layer MLP , when appropriately configured with a sufficient number of neurons , is a universal approximator for any Borel measurable function . The pre-processing MLP of the general GNCA architecture is therefore sufficient to compute any desired representation of the states . Then , building on the results of Zaheer et al . [ 23 ] , we can also see that the structure of the GNCA allows us to model any permutation invariant function of the neighbours . Finally , by concatenating the representation of a node to the representation of its neighbours and giving the result as input to the post-processing MLP , we are also able to compute any transition to the following state . Of course , these results are conditioned on the two MLPs being sufficiently large , and there are no guarantees that the training algorithm will be able to identify the correct function .

Summary: The paper presents the Graph Neural Cellular Automata (GNCA) architecture, a general-purpose architecture that uses a Graph Neural Network (GNN) to learn a desired Graph Cellular Automata (GCA). The proposed architecture is used to learn different transition rules in different kinds of space (discrete and continuous). In the paper, there is a brief (but complete) introduction to Graph Cellular Automata and Graph Neural Network. The GNCA architecture borns by the natural and clearly explained connection between GNN and GCA. The effectiveness of this architecture is demonstrated by three experiments that explore different scenarios: learning a transition rule via supervised learning in a discrete state space, learning a transition rule in a continuous state space, and learning an unknown transition rule to reproduce a target. Each result is discussed using different metrics in order to evaluate how well the model performs in that particular setting.