Symbolic Synthesis of Neural Networks
Neural networks adapt very well to distributed and continuous
representations, but struggle to generalize from small amounts of data.
Symbolic systems commonly achieve data efficient generalization by exploiting
modularity to benefit from local and discrete features of a representation.
These features allow symbolic programs to be improved one module at a time and
to experience combinatorial growth in the values they can successfully process.
However, it is difficult to design a component that can be used to form
symbolic abstractions and which is adequately overparametrized to learn
arbitrary high-dimensional transformations. I present Graph-based Symbolically
Synthesized Neural Networks (G-SSNNs), a class of neural modules that operate
on representations modified with synthesized symbolic programs to include a
fixed set of local and discrete features. I demonstrate that the choice of
injected features within a G-SSNN module modulates the data efficiency and
generalization of baseline neural models, creating predictable patterns of both
heightened and curtailed generalization. By training G-SSNNs, we also derive
information about desirable semantics of symbolic programs without manual
engineering. This information is compact and amenable to abstraction, but can
also be flexibly recontextualized for other high-dimensional settings. In
future work, I will investigate data efficient generalization and the
transferability of learned symbolic representations in more complex G-SSNN
designs based on more complex classes of symbolic programs. Experimental code
and data are available at
https://github.com/shlomenu/symbolically_synthesized_networks .
Eli Whitehouse
# Symbolic Synthesis of Neural Networks

###### Abstract

Neural networks adapt very well to distributed and continuous representations, but struggle to generalize from small amounts of data. Symbolic systems commonly achieve data efficient generalization by exploiting modularity to benefit from local and discrete features of a representation. These features allow symbolic programs to be improved one module at a time and to experience combinatorial growth in the values they can successfully process. However, it is difficult to design a component that can be used to form symbolic abstractions and which is adequately overparametrized to learn arbitrary high-dimensional transformations. I present Graph-based Symbolically Synthesized Neural Networks (G-SSNNs), a class of neural modules that operate on representations modified with synthesized symbolic programs to include a fixed set of local and discrete features. I demonstrate that the choice of injected features within a G-SSNN module modulates the data efficiency and generalization of baseline neural models, creating predictable patterns of both heightened and curtailed generalization. By training G-SSNNs, we also derive information about desirable semantics of symbolic programs without manual engineering. This information is compact and amenable to abstraction, but can also be flexibly recontextualized for other high-dimensional settings. In future work, I will investigate data efficient generalization and the transferability of learned symbolic representations in more complex G-SSNN designs based on more complex classes of symbolic programs. Experimental code and data are available here.

 neural networks symbolic programs graph neural networks library learning distributional program search

## 1 Introduction

Most conventional modes of human communication naturally occur in a high-dimensional medium such as text, audio, or images. When processing these media, slight errors can easily accrue across many dimensions of the input where features are distributed. With adequate data, neural networks adapt effectively to these patterns by adjusting many interdependent real-valued parameters. In their basic form, however, neural models are data inefficient. In settings where more data cannot be sourced, pretraining has arisen as the most general and data-driven answer to this challenge. Pretraining allows practitioners to repurpose data that is not specifically suited to a task to enrich a representation or initialize parameters of a neural model. While pretraining grants a model exposure to out-of-distribution data which may be irrelevant or inappropriate to the task at hand, the benefits of this exposure can outweigh the costs.

In symbolic systems, modularity can allow for greater data efficiency and generalization in the presence of local and discrete features. By examining the particular dimensions of an input which cause systems to fail, developers can trace issues back to specific modules. When a failure in one module is corrected, the system benefits from this across all combinations of values and dimensions, witnessing potentially exponential growth in the number of inputs on which it succeeds. In contrast to pretraining, the use of modular functionalities to process local and discrete features offers a direct solution to the challenge of data efficient generalization. However, it is difficult to design a unit that is appropriate both for learning arbitrary high-dimensional transformations, and for composing symbolic abstractions, as the overparametrization that gives neural networks their flexibility also makes their semantics unstable. This makes it difficult to judge which combinations of primitive operations are useful enough to merit the creation of a new abstractions.
I present a novel approach based on Graph-based Symbolically Synthesized Neural Networks (G-SSNNs), a form of neural module in which symbolic abstraction and gradient-based learning play complementary roles. In a G-SSNN, the output of a symbolic program is used to determine a set of local and discrete features that are injected into the representations processed by the network. The symbolic program is chosen by an evolutionary algorithm, which is used to develop and evaluate a population of G-SSNNs with varying designs. Through the use of distributional program search and library learning--a mechanism for identifying useful new abstractions--the evolutionary algorithm may influence both the content of injected features and the degree of locality they exhibit. In this work, I apply evolving populations of G-SSNNs to a binary prediction task over high-dimensional data that humans find simple and easy to interpret from handfuls of examples. I show that these populations exhibit a reliable pattern of both heightened and curtailed generalization relative to baseline models after training on small quantities of data.

## 2 G-SSNNs

In a G-SSNN, the output of a symbolic program fixes a mechanism that injects a set of local and discrete features into the input. A graph may be used to represent not just these individual features as node and edge representations, but also their relationships to each other. After a symbolic program has generated a graph \(g\in G_{k}\) with symbolic node and edge representations \(v\in\mathbb{N}^{k}\), we may embed arbitrary input vectors into this structure piecewise with a function \(e\colon\mathbb{N}^{k}\times\mathbb{R}^{m}\to\mathbb{R}^{q}\). Each symbolic feature thus provides an instruction as to how a region of the input vector should be transformed. With \(\texttt{graph\_map}_{e}:G_{k}\times\mathbb{R}^{m}\to G^{\prime}_{q}\), a function that applies \(e\) for each symbolic feature \(v\in g\), we compute a graph \(g^{\prime}\in G^{\prime}_{q}\) with transformed, real-valued features which may be processed by a standard GNN \(m_{gnn}:G^{\prime}_{q}\to\mathbb{R}^{n}\). The G-SSNN \(m:\mathbb{R}^{m}\to\mathbb{R}^{n}\) is then a triplet of \(g\), \(e\), and \(m_{gnn}\) used to compute

\[m(x)=m_{gnn}(\texttt{graph\_map}_{e}(g,x)).\]

Provided that \(e\) is differentiable with respect to \(x\), the G-SSNN \(m\) may be augmented with a readout or global pooling function to create a generic neural module. There are many definitions of \(G_{k}\) and \(e\) practitioners may adopt depending on the intended role of the injected features. The definitions used in this work are presented in section A.1 of the appendix.

## 3 Evolutionary Framework

While the GNN of a G-SSNN can be trained with standard gradient-based optimization techniques, its graph structure is a hyperparameter whose values must be explored with search. To conduct this search, I repurpose the cycle of library learning and distributional program search pioneered by the DreamCoder system (Ellis et al., 2021) within an evolutionary framework, incorporating the improved STITCH library learning tool of Bowers et al. (2023) and heap search algorithm of Matricon et al. (2022). As in DreamCoder, I perform rounds of library learning and distributional program search, after which I evaluate the current crop of programs on the task. Unlike symbolic programs, however, G-SSNNs may exhibit widely-varying degrees of generalization. As such, it is not appropriate to take their performance on a handful of training examples as indicative of goodness of fit. Rather, a heuristic must be applied to select those symbolic programs whose corresponding G-SSNNs are expected to generalize best based on their training performance. G-SSNNs, along with such a heuristic, may be understood as generalizing the evaluation mechanisms used for symbolic programs within the DreamCoder system. In this work, I develop a single population of G-SSNNs for application to a single task. However, in principle, nothing prevents the multitask Bayesian program learning framework of the DreamCoder system from being applied to the development of multiple populations of G-SSNNs.

After each evolutionary step, a new population is produced for each task. At the next step of library learning, novel primitives are judged according to which provide the greatest degree of compression of this corpus (i.e. reduction in the number of primitives needed to express a program). The creation of new primitives is therefore guided by the pruning of the population that has occurred at previous stages. By inferring the distribution of unigrams of primitives in the current population, we may guide search towards programs that utilize these primitives at similar frequencies. Through these mechanisms, the choice of heuristic influences the evolution of future G-SSNN designs. Though no heuristic is best in all cases, the class of heuristics that discard models with the Lowest Training Performance (LTP) is simple and agreeable for a wide variety of applications. In this work, I utilize a heuristic I refer to as rank-LTP-50, which directs that the bottom half of G-SSNNs in terms of ranked training performance be discarded at each step of evolution. For additional details on the search space explored with these techniques, see section A.2 of the appendix.
## 4 Related Work

Neural Architecture Search (NAS) is the process of using automated methods to explore the discrete space of neural network topologies. In a G-SSNN \(m\), the symbolic program may be considered to influence the topology of the model through its role in structuring the applications of graph convolutions within \(m_{gmn}\), and also through its role in distinguishing dimensions of the input through the embedding function \(e\). However, despite variation in the design of their search space (Jin et al., 2022), search strategies (Real et al., 2020), and model evaluation strategies (Abdelfattah et al., 2021), all approaches I reviewed assume that parameters will be learned with gradient-based optimization before each model is assessed. This differs from G-SSNNs, as the embedding function described in section A.1 includes a term whose function is equivalent to that of a bias parameter, yet remains static throughout gradient-based learning. The act of adding features to a representation through a static mechanism seems more analogous to an act of preprocessing, as might be performed with word embeddings (Mikolov et al., 2013) or positional encoding (Vaswani et al., 2017). However, I found no works in which similar acts of preprocessing were designed with the help of distributional program search and library learning. G-SSNNs draw significant inspiration from the DreamCoder system; however, I did not find examples of neurosymbolic systems in which adjacent parametric and nonparametric mechanisms are separately optimized through gradient-based learning and library learning.

## 5 Experiments

### Setup & Hyperparameters

To facilitate comparison, I utilize a base model architecture consisting of a transformer with a convolutional stem (Xiao et al., 2021). I use subpixel convolution to perform downsampling from \(128\times 128\) to \(8\times 8\)(Shi et al., 2016), followed by a pointwise convolution and three residual convolutional units. The patches are then flattened and fed to a simplified Vision Transformer (ViT) (Beyer et al., 2022) with 2 transformer blocks. Each block has an MLP dimension of 512 and 4 128-dimensional attention heads. Global average pooling is then applied to produce an output of the target dimension for baseline models, or with the dimensionality of a node/edge representation for experimental models in which the output is fed to a G-SSNN unit.

To construct G-SSNNs, I use the Graph Isomorphism Network with Edge features (GINE) of Hu et al. (2020) as implemented in the DGL library (Wang et al., 2019). I use 512-dimensional node and edge representations, which are passed through three GINE layers parametrized by an MLP with identical input and output dimensionalities. Between GINE layers, I apply 30% dropout (Srivastava et al., 2014). To produce the final output, I apply average pooling followed by another MLP which projects its input to the target output.

For both baseline and experimental models I use a batch size of 8, train each model for 16 epochs with the Adam optimizer (Kingma and Ba, 2015), and reduce the learning rate by a factor of 1/2 when a new low in the loss has not been experienced in the first 50 batches, or in the most recent 65 batches since the learning rate was last reduced.

Across iterations of evolutionary selection, I retain a population of at most 50 and apply the rank-LTP-50 heuristic if the size of the population is greater than or equal to 25. I run distributional program search for a 15 second period. In the course of this run, I retain only the most likely \(50-\)population_size novel programs; however, if programs are discovered that are shorter than, but semantically equivalent to, programs currently in the population, these shorter reformulations are kept and their equivalents are set aside. I do not consider programs that consist of more than 150 primitives from the most updated DSL. Prior to program search, I reweight the parameters of the program distribution such that the log likelihoods of the most and least likely primitives differ by no more than 0.5. I implemented this transformation such that it preserves the relative distance of each primitive's log likelihood from the mean and therefore does not alter the DSL's total probability mass.1 During library learning, I perform up to three rounds of compression, each producing a primitive of arity 2 or less. All other parameters of the STITCH compression routine were allowed to take their default values.2

Footnote 1: This and other domain-general aspects of program search are implemented in the antireduce library.

Footnote 2: Explanation of these settings may be found in the documentation of the stitch_core Python package.

### Dataset

The RAVEN dataset (Zhang et al., 2019) is an artificial dataset consisting of visual puzzles known as Raven's Progressive Matrices (RPMs). Originated as a psychometric test, RPMs have since been extensively studied as tests of Abstract Visual Reasoning (AVR) in both symbolic and neural AI systems. An RPM is a \(9\times 9\) matrix of panels depicting simple arrangements of polygons. Within each row, panels exhibit one of a handful of consistent patterns with respect to each
attribute-size, shape, color, angle, position, and multiplicity-of their polygons. These patterns are easily observed by humans from relatively few examples. In comparison, neural models typically require orders of magnitude more data to match or surpass human performance.

Classically, the final panel of the last sequence (bottom right) is omitted and some number of candidate panels are provided, only one of which contains polygons which obey the same patterns exhibited in the first two rows for all attributes. The goal of the solver is to distinguish the correct panel from the pool of candidates. Odouard and Mitchell (2022) have demonstrated that several recent high-performing neural models from the RAVEN literature perform poorly when more exhaustively evaluated on their understanding of the various instantiations of an individual pattern. This inspired the Prediction of Constant Color Pattern (PCCP) task, a binary prediction task in which a model examines a complete and correct RPM and predicts whether it exhibits constancy of polygon color across rows. The two classes in this task-constant and non-constant-were relatively evenly-distributed among generated data without additional constraints on pattern instantiation or attribute values.3 Furthermore, color is unrelated to and unaffected by the settings of other attributes, so indiscernible spurious correlation with the presence or absence of other pattern-attribute pairings is unlikely, even with small data.

Footnote 3: Some constraints on pattern instantiation and attribute values were necessary to ensure legibility at the desired resolution of \(128\times 128\). Specifically, polygon size was kept large and not allowed to vary and oblique angles of polygon rotation were disallowed. Neither of these constraints contribute to determining the color constancy of an RPM.

The RAVEN-like data used in my experiments were generated with a reimplementation of the original RAVEN data generation code extended to support creation of RPMs at lower resolutions than were originally accommodated. I use a training dataset size of 128 RPMs and a validation set of 1200 RPMs. These sizes make it easy to fit to the training data, but difficult to generalize without appropriate inductive biases.

Figure 1: Training and validation set performances of populations of neural networks. Each model of a population is represented in both unsmoothed trend lines of a plot at parallel points with respect to the x-axis. Parallel points are sorted in descending order of training set accuracy. The baseline plot depicts the spread of training and validation set accuracies for 50 instantiations of a baseline model. The experimental plots depict the spread of training set and validation set accuracies for populations of G-SSNNs at various stages of evolution. At stage \(n\), the population has undergone \(n\) rounds of heuristic selection and program synthesis. At iterations 1-5, the populations were of sizes 2, 7, 44, 50 and 50, respectively. Dotted lines represent unsmoothed data and solid lines represent smoothed data with a window size of 6. I present validation set accuracies in both smooth and unsmoothed form except where the population of models seem too small to meaningfully benefit from smoothing (\(n<15\)).
### Results

Figure 1 presents comparative results for populations of baseline and experimental models. Generally, experimental models exhibit a much smaller gap in performance between seen and unseen data than baseline models do. For both baseline and experimental models, validation set accuracy is highest for models whose training set accuracy is in the range of 80-90%. Among baseline models less than 20% fall in this range. After the first iteration, 30% or more of the population of experimental models fall in this range. For both baseline and experimental models, validation set accuracy is lowest for models whose training set accuracy falls below 80%. While only one or two baseline models fall in this range, by the third iteration 20% or more of experimental models fall in this range. The experimental condition thus makes both peak validation set accuracies and degraded validation set accuracies more numerous, providing evidence that the use of G-SSNN modules modulates the data efficiency and generalization of the baseline model. It also appears that among experimental models, there is a clearer relationship between training set accuracy and validation set accuracy, making it easier to select models that exhibit goodness of fit on both seen and unseen data.

The distributions of validation set accuracies illustrated in these data suggest that it is actually models with a training set performance of a more intermediate rank that are most likely to exhibit peak generalization. In these models, injected features raise validation set performance without lowering training set performance to a harmful degree. In future work and applications of G-SSNNs, it may therefore be beneficial to explore the space of Intermediate Training Performance (ITP) heuristics for selecting from the population.

## 6 Discussion

Across high-dimensional media, there are tasks that require data efficient generalization. In these settings, modular systems may be better at responding to local and discrete features that simplify and accelerate learning. In G-SSNNs, we stimulate modularity by injecting a fixed set of local and discrete features which the model must contextualize for the task at hand. This allows G-SSNN modules to be trained with standard techniques. By training G-SSNNs, we also derive information about desirable semantics of symbolic programs without manual engineering. Unlike the knowledge contained in neural network weights, this information can be abstracted upon just as the functions of handwritten software libraries are today. However, unlike the knowledge contained in purely symbolic systems, it can also be flexibly adapted to high-dimensional settings in ways that cannot be concisely expressed with symbols. In advancing this paradigm, I believe that G-SSNNs capture much of what is desirable about the promise of common sense: the ability to quickly adapt and elaborate on compact knowledge in a range of perceptually-grounded circumstances.

In future work, I will investigate data efficient generalization and the transferability of learned symbolic representations in more complex G-SSNN designs based on more complex classes of symbolic programs. Such programs could include operations that create more varied node and edge features and access richer external sources of information to inform their values. Based on these features, embedding functions could utilize more complex topological structures, or incorporate transformations from pretrained models.

## 7 Conclusion

I have presented G-SSNNs, a class of neural modules whose representations are modified with synthesized symbolic programs to include a fixed set of local and discrete features. I presented the results of applying neural models containing G-SSNN modules to a binary prediction task over Raven's Progressive Matrices (RPMs), psychometric tests of Abstract Visual Reasoning (AVR) on which humans exhibit data efficient generalization. These results demonstrate that the injected features of G-SSNNs modulate the data efficiency and performance of baseline neural models. In addition to their potential to improve data efficiency and generalization on tasks involving high-dimensional transformations, G-SSNNs also allow us to derive information about the desirable semantics of symbolic programs without manual engineering. This information is compact and amenable to abstraction, and can also be flexibly contextualized for other high-dimensional settings in response to data. In future work, I will investigate data efficient generalization and the transferability of learned symbolic representations in more complex G-SSNN designs based on more complex classes of symbolic programs.
