Reasoning-Modulated Representations
Abstract
Neural networks leverage robust internal representations in order to generalise.
Learning them is difficult, and often requires a large training set that covers the data distribution densely.
We study a common setting where our task is not purely opaque.
Indeed, very often we may have access to information about the underlying system (e g. that observations must obey certain laws of physics) that any “tabula rasa” neural network would need to re-learn from scratch, penalising performance.
We incorporate this information into a pre-trained reasoning module, and investigate its role in shaping the discovered representations in diverse selfsupervised learning settings from pixels.
Our approach paves the way for a new class of representation learning, grounded in algorithmic priors.
Introduction
Neural networks are able to learn policies in environments without access to their specifics [1], generate large quantities of text [2], or automatically fold proteins to high accuracy [3].
However, such “tabula rasa” approaches hinge on having access to substantial quantities of data, from which robust representations can be learned.
Without a large training set that spans the data distribution, representation learning is difficult [4–6].
Here, we study ways to construct neural networks with representations that are robust, while retaining a data-driven approach.
We rely on a simple observation: very often, we have some (partial) knowledge of the underlying dynamics of the data, which could help make stronger predictions from fewer observations.
This knowledge, however, usually requires us to be mindful of abstract properties of the data—and such properties cannot always be robustly extracted from natural observations.
[Equation]
c , ¯ x red ) (cid:19)
¯ y blu ¯ y org ¯
y yel
¯ y
pur ¯ y grn
Motivation.
Consider the task of predicting the future state of a system of n bouncing balls, from a pixel input x (Figure 1).
Reliably estimating future pixel observations, y , is a challenging reconstruction task.
However, the generative properties of this system are simple.
Assuming knowledge of simple abstract inputs (radius, r c , position, x c , and velocity, v c ) for every ball, ¯ x c , the future movements in this abstract space are the result of applying the laws of physics to these low-dimensional quantities.
Hence, future abstract states, ¯ y , can be computed via a simple algorithm that aggregates pair-wise forces between objects.
While this gives us a potentially simpler path from pixel inputs to pixel outputs, via abstract inputs to abstract outputs ( x → ¯ x ⇝ ¯ y → y ), it still places potentially unrealistic demands on our task setup, every step of the way:
x → ¯ x : Necessitates either upfront knowledge of how to abstract away ¯ x from x , or a massive dataset of paired ( x , ¯ x ) to learn such a mapping from; ¯ x ⇝ ¯ y : Implies that the algorithm perfectly simulates all aspects of the output.
In reality, an algorithm may often only give partial context about y .
Further, algorithms often assume that x is provided without error, exposing an algorithmic bottleneck [8]: if ¯ x is incorrectly predicted, this will negatively compound in ¯ y , hence y ; ¯ y → y : Necessitates a renderer that generates y from ¯ y , or a dataset of paired (¯ y , y ) to learn it.
We will assume a general setting where none of the above constraints hold: we know that the mapping ¯ x ⇝ ¯ y is likely of use to our predictor, but we do not assume a trivial mapping or a paired dataset which would allow us to convert directly from x to ¯ x or from ¯ y to y .
Our only remaining assumption is that the algorithm ¯ x ⇝ ¯ y can be efficiently computed, allowing us to generate massive quantities of paired abstract input-output pairs, (¯ x , ¯ y ) .
Present work.
In this setting, we propose Reasoning-Modulated Representations (RMR), an approach that first learns a latent-space processor of abstract data; i.e. a mapping ¯ x f −→ z P −→ z ′ g −→ ¯ y , where z ∈ R k are high-dimensional latent vectors.
f and g are an encoder and decoder, designed to take abstract representations to and from this latent space, and P is a processor network which simulates the algorithm ¯ x
⇝ ¯ y in the latent space.
We then observe, in the spirit of neural algorithmic reasoning [9], that such a processor network can be used as a drop-in differentiable component for any task where the ¯ x ⇝ ¯ y kind of reasoning may be applicable.
Hence, we then learn a pipeline x
˜ f −→ z P −→ z ′ ˜
g −→ y , which modulates the representations z obtained from x , forcing them to pass through the pre-trained processor network.
By doing so, we have ameliorated the original requirement for a massive natural dataset of ( x , y ) pairs.
Instead, we inject knowledge from a massive abstract dataset of (¯ x , ¯ y ) pairs, directly through the pre-trained parameters of P .
This has the potential to relieve the pressure on encoders and decoders ˜ f
and ˜ g , which we experimentally validate on several challenging representation learning domains.
Our contributions can be summarised as follows:
• Verifying and extending prior work, we show that meaningful latent-space models can be learned from massive abstract datasets, on physics simulations and Atari 2600 games; • We then show that these latent-space models can be used as differentiable components within neural pipelines that process raw observations.
In doing so, we recover a neural network pipeline that relies solely on the existence of massive abstract datasets (which can often be automatically generated).
• Finally, we demonstrate early signs of processor reusability : latent-space abstract models can be used in tasks which do not even directly align with their environment, so long as these tasks can benefit from their underlying reasoning procedure.
Related Work
Neural algorithmic reasoning.
RMR relies on being able to construct robust latent-space models, akin to world models [10], that imitate abstract reasoning procedures.
This makes it well aligned with neural algorithmic reasoning [11], which is concerned with constructing neuralised versions of classical algorithms (typically by learning to execute them in a manner that extrapolates).
Leveraging the ideas of algorithmic alignment [12], several known algorithmic primitives have already been successfully neuralised.
This includes iterative computation [13, 14], linearithmic algorithms [15], and data structures [16, 17].
Further, the XLVIN model [8] demonstrates how such primitives can be re-used for data-efficient planning, paving the way for a blueprint [9] that we leverage in RMR as well.
Our work also relates to transferring algorithmic reasoning knowledge [18], where no evidence of positive transfer was found, in case of cross-algorithm transfer, whereas we did in the case of transfer among aligned algorithms (same underlying algorithm from abstract to raw inputs.)
Physical simulation with neural networks.
Our work also has contact points with prior art in using (graph) neural networks for physics simulations .
In fact, there is a tight coupling between algorithmic computation and simulations, as the latter are typically realised using the former.
Within this space, abstract GNN models of physics have been proposed by works such as interaction networks [7] and NPE [19], and extended to pixel-based inputs by visual interaction networks [20].
The generalisation power of these models has increased drastically in recent years, with effective models of systems of particles [21] as well as meshes [22] being proposed.
Excitingly, it has also been demonstrated that rudimentary laws of physics can occasionally be recovered from the update rules of these GNNs [23], and that they can be used to uncover new physical knowledge [24].
Recent work has also explored placing additional constraints on learning-based physical simulators, for example by using Hamiltonian ODE integrators in conjunction with GNN models [25], or by coupling a (non-neural) differentiable physics engine directly to visual inputs and optimizing its parameters via backprop [26, 27].
Object-centric and modular models for dynamic environments.
RMR with factored latents can be viewed as a form of object-centric neural network , in which visual objects in an image or video are represented as separate latent variables in the model and their temporal dynamics and pairwise interactions are modeled via GNNs or self-attention mechanisms.
There is a rich literature on discovering objects and learning their dynamics from raw visual data without supervision, with object-centric models such as R-NEM [28], SQAIR [29], OP3 [30], SCALOR [31], G-SWM [32].
Recent work has explored using contrastive losses [33] in this context or other losses directly in latent space [34].
Related approaches discover and use keypoints [35] to describe objects and even discover causal relations from visual input [36] using neural relational inference [37] in conjunction with a keypoint discovery method.
A related line of works integrate attention-mechanisms in modular and object-centric models to interface latent variables with visual input, including models such as
RMC [38], RIM [39], Slot Attention [40], SCOFF [41], and NPS [42].
RMR architecture
Having provided a high-level overview of RMR and surveyed the relevant related work, we proceed to carefully detail the blueprint of RMR’s various components.
This will allow us to ground any subsequent RMR experiments on diverse domains directly in our blueprint.
Throughout this section, it will be useful to refer to Figure 2 which presents a visual overview of this section.
Preliminaries.
We assume a set of natural inputs , X , and a set of natural outputs , Y .
These sets represent the possible inputs and outputs of a target function, Φ : X → Y , which we would like to learn based on a (potentially small) dataset of input-output pairs, ( x , y ) , where y =
Φ( x ) .
We further assume that the inner workings of Φ can be related to an algorithm , A : ¯ X → ¯ Y .
The algorithm operates over a set of abstract inputs , ¯ X , and produces outputs from an abstract output set ¯ Y .
Typically, it will be the case that dim ¯ X ≪ dim X ; that is, abstract inputs are assumed substantially lower-dimensional than natural inputs.
We do not assume existence of any aligned input pairs ( x , ¯ x ) , and we do not assume that A perfectly explains the computations of Φ .
What we do assume is that A is either known or can be trivially computed, giving rise to a massive dataset of abstract input-output pairs, (¯ x , ¯ y ) , where ¯ y
=
A (¯ x ) .
Lastly, we assume a latent space , Z , and that we can construct neural network components to both encode and decode from it.
Typically, Z will be a real-valued vector space ( Z = R k ) which is high-dimensional; that is, k > dim ¯ X .
This ensures that any neural networks operating over Z are not vulnerable to bottleneck effects.
¯ x ¯ x blu ¯ x red ¯ x org ¯
x yel ¯ x pur ¯ x grn
Abstract inputs z zzzzzz
Latents ¯ y ¯ y blu ¯
y red ¯ y org ¯
y yel
¯ y
pur ¯ y grn
Abstract outputs x
Natural inputs y
Natural outputs f g
P ˜ f ˜ g
Note that either the natural or abstract input set may be factorised , e.g., into objects; in this case, we can accordingly factorise the latent space, enforcing Z = R n × k , where n is the assumed maximal number of objects (typically a hyperparameter of the models if not known upfront).
Abstract pipeline.
RMR training proceeds by first learning a model of the algorithm A , which is bound to pass through a latent-space representation.
That is, we learn a neural network approximator g ( P ( f (¯ x )))
≈ A (¯ x ) , which follows the encode-process-decode paradigm [43].
It consists of the following three building blocks: Encoder, f : ¯ X → Z , tasked with projecting the abstract inputs into the latent space; Processor, P : Z → Z , simulating individual steps of the algorithm in the latent space; Decoder, g : Z → ¯ Y , tasked with projecting latents back into the abstract output space.
Such a pipeline is now widely used both in neural algorithmic reasoning [13] and learning physical simulations [21], and can be trained end-to-end with gradient descent.
For reasons that will become apparent, it is favourable for most of the computational effort to be performed by P .
Accordingly, encoders and decoders in the abstract pipeline are often designed to be simple learnable linear projections as there is usually no need for elaborate encoders/decoders, which, we will see, is not the case in the natural pipeline, due to nontrivial geometry of inputs and outputs.
The processors tend to be either deep MLPs or graph neural networks—depending on whether the latent space is factorised into nodes.
Natural pipeline.
Once an appropriate processor, P , has been learned, it may be observed that it corresponds to a highly favourable component in our setting.
Namely, we can relate its operations to the algorithm A , and since it stays high-dimensional, it is a differentiable component we can easily plug into other neural networks without incurring any bottleneck effects.
This insight was originally recovered in XLVIN [8], where it yielded a generic implicit planner.
As an ablation, we have also rediscovered the bottleneck effect in our settings; see Appendix C. We now leverage similar insights for general representation learning tasks.
On a high level, what we need to do is simple and elegant: swap out f and g for natural encoders and decoders, ˜ f : X → Z and ˜ g : Z → Y , respectively.
We are then able to learn a function ˜
g ( P ( ˜ f
( x )))
≈ Φ( x ) , which is once again to be optimised through gradient descent.
We would like P to retain its semantics during training, and therefore it is typically kept frozen in the natural pipeline.
Note that P might not perfectly represent A which in turn might not perfectly represent Φ .
While we rely on a skip connection in our implementation of P , it has no learnable parameters and does not offer the system the ability to learn a correction of P in the natural setting.
Our choice is motivated by the desire to both maintain the semantics and interpretability of P and to force the model to rely on the processor P , not to simply bypass it.
We show empirically that our pipeline is surprisingly robust to imperfect P models even with weak (linear) encoders/decoders.
It is worth noting several potential challenges that may arise while training the natural pipeline, especially if the training data for it is sparsely available.
We also suggest remedies for each:
• If x and/or y exhibit any nontrivial geometry, simple linear projections will rarely suffice for ˜ f and ˜ g .
For example, our natural inputs will often be pixel-based, necessitating a convolutional neural network for ˜ f .
• Further, since the parameters of P are kept frozen, ˜ f is left with a challenging task of mapping natural inputs into an appropriate manifold that P can meaningfully operate over.
While we demonstrate clear empirical evidence that such meaningful mappings definitely occur, we remark that its success may hinge on carefully tuning the hyperparameters of ˜ f .
• A very common setting assumes that the abstract inputs and latents are factorised into objects, but the natural inputs are not.
In this case, ˜ f is tasked with predicting appropriate object representations from the natural inputs.
This is known to be a challenging feat [44], but can be successfully performed.
Sometimes arbitrarily factorising the feature maps of a CNN [33] is sufficient, while at other times, models such as slot attention [40] may be required.
• One corollary of using automated object extractors for ˜ f is that it’s very difficult to enforce their slot representations to line up in the same way as in the abstract inputs.
This implies that P should be permutation equivariant (and hence motivates using a GNN for it).
RMR for bouncing balls
To evaluate the capability of the RMR pipeline for transfer from the abstract space to the pixel space, we apply it on the “bouncing balls” problem.
The bouncing balls problem is an instance of a physics simulation problem, where the task is to predict the next state of an environment in which multiple balls are bouncing between each other and a bounding box.
Though this problem had been studied in the the context of physics simulation from (abstract) trajectories [7] and from (natural) videos [20, 28, 45], here we focus on the aptitude of RMR to transfer learned representations from trajectories to videos.
Our results affirm that strong abstract models can be trained on such tasks, and that including them in a video pipeline induces more robust representations.
See Appendix A for more details on hyperparameters and experimental setup.
Preliminaries.
Here, trajectories are represented by 2D coordinates of 10 balls through time, defining our abstract inputs and outputs ¯ X = ¯ Y
= R 10 × 2 .
We slice these trajectories into a series of moving windows containing the input, ¯ x ∗ , spanning a history of three previous states, and the target, ¯ y , representing the next state.
We obtain these trajectories from a 3D simulator (MuJoCo [46]), together with their short-video renderings, which represent our natural input and output space
X =
Y = R 64 ×
×
Our goal is to train an RMR abstract model on trajectories and transfer learned representations to improve a dynamics model trained on these videos.
Abstract pipeline.
So as to model the dynamics of trajectories, we closely follow the RMR desiderata for the abstract model.
We set f to a linear projection over the input concatenation, P to a Message Passing Neural Network (MPNN), following previous work [7, 21], and g to a linear projection.
Our model learns a transition function g ( P ( f (¯ x ∗ ))
≈ ¯ y , supervised using Mean Squared Error (MSE) over ball positions in the next step.
It achieves an MSE of 4 .
59 × 10 − 4 , which, evaluated qualitatively, demonstrates the ability of the model to predict physically realistic behavior when unrolled for 10 steps (the model is trained on 1-step dynamics only).
Next, we take the processor P from the abstract pipeline and re-use it in the natural pipeline.
Natural pipeline.
Here we evaluate whether the pre-trained RMR processor can be reused for learning the dynamics of the bouncing balls from videos.
The pixel-based encoder ¯ f simply runs a
Slot Attention model [40] on each input image, concatenates its outputs and passes them through a linear layer.
The pixel-based decoder ¯ g is a Broadcast Decoder [47].
The full model is a transition function ¯ g ( P ( ¯ f ( x ∗ ))
≈ y , supervised by pixel reconstruction loss over the next step image.
We compare the performance of the RMR model with a pre-trained processor
P against a baseline in which P is trained fully end-to-end.
The RMR model achieves an MSE of 7 . 94 ± 0 .
41 ( × 10 − 4 ) , whereas the baseline achieves 9 .
47 ± 0 .
24 ( × 10 − 4 ) .
We take a qualitative look at the reconstruction rollout of the RMR model in Figure 3, and expose the algorithmic bottleneck properties for this task in Appendix C.
Contrastive RMR for Atari
We evaluate the potential of our RMR pipeline for state representation learning on the Atari 2600 [48].
We find the RMR applicable here because there is a potential wealth of information that can be obtained about the Atari’s operation—namely, by inspecting its RAM traces.
Preliminaries.
Accordingly, we will define our set of abstract inputs and outputs as Atari RAM matrices.
Given that the Atari has 128 bytes of memory, ¯ X = ¯ Y =
B 128 × 8 (where B = { 0 , 1 } is the set of bits).
We collect data about how the console modifies the RAM by acting in the environment and recording the trace of RAM arrays we observe.
These traces will be of the form (¯ x , a, ¯ y ) which signify that the agent’s initial RAM state was ¯ x , and that after performing action a ∈ A , its RAM state was updated to ¯ y .
We assume that a is encoded as an 18-way one-hot vector.
We would like to leverage any reasoning module obtained over RAM states to support representation learning from raw pixels.
Accordingly, our natural inputs, X , are pixel arrays representing the Atari’s framebuffer.
Mirroring prior work, we perform contrastive learning directly in the latent space, and set Y
=
Z ; that is, our natural outputs correspond to an estimate of the “updated” latents after taking an action.
All our models use latent representations of 64 dimensions per slot, meaning Z = R 128 × 64 .
We note that it is important to generate a diverse dataset of experiences in order to train
a robust
RAM model.
To simulate a dataset which might be gathered by human players of varying skill, we sample our data using the 32 policy heads of a pre-trained Agent57 [49].
Each policy head collects data over three episodes in the studied games.
Note that this implies a substantially more challenging dataset than the one reported by Anand et al.
[50], wherein data was collected by a purely random policy, which may well fail to explore many relevant regions of the games.
Abstract pipeline.
Firstly, we set out to verify that it is possible to train nontrivial Atari RAM transition models.
The construction of this abstract experiment follows almost exactly the abstract
RMR setup: f and g are appropriately sized linear projections, while P needs to take into account which action was taken when updating the latents.
To simplify the implementation and allow further model re-use, we consider the action a part of the P ’s inputs.
See Appendix F for detailed equations.
This implies that our transition model learns a function g ( P ( f (¯ x ) , a ))
≈ ¯ y .
We supervise this model using binary cross-entropy to predict each bit of the resulting RAM state.
Since RAM transitions are assumed deterministic, we assume a fully Markovian setup and learn 1-step dynamics.
For brevity purposes, we detail our exact hyperparameters and results per each Atari game considered in
Appendix B.
Our results ascertain the message passing neural network (MPNN) [51] as a highly potent processor network in Atari: it ranked most potent in 17 out of 24 games considered, compared to MLPs and Deep Sets [52].
Accordingly, we will focus on leveraging pre-trained MPNN processors for the next phase of the RMR pipeline.
Natural pipeline.
We now set out to evaluate whether our pre-trained RMR processors can be meaningfully re-used by an encoder in a pixel-based contrastive learning pipeline.
[Table]
For our pixel-based encoder ˜ f , we use the same CNN trunk as Anand et al.
[50]—however, as we require slot-level rather than flat embeddings, the final layers of our encoder are different.
Namely, we apply a 1 × 1 convolution computing 128 m feature maps (where m is the number of feature maps per-slot).
We then flatten the spatial axes, giving every slot m × h × w features, which we finally linearly project to 64-dimensional features per-slot, aligning with our pre-trained P .
Note that setting m = 1 recovers exactly the style of object detection employed by C-SWM [33].
Since our desired outputs are themselves latents, ˜ g is a single linear projection to 64 dimensions.
Overall, our pixel-based transition model learns a function ˜
g ( P ( ˜ f
( x ) , a ))
≈ ˜ f
( y ) , where y is the next state observed after applying action a in state x .
To optimise it, we re-use exactly the same
TransE-inspired [53] contrastive loss that C-SWM [33] used.
Once state representation learning concludes, all components are typically thrown away except for the encoder, ˜ f , which is used for downstream tasks.
As a proxy for evaluating the quality of the encoder, we train linear classifiers on the concatenation of all slot embeddings obtained from ˜ f to predict individual RAM bits, exactly as in the abstract model case.
Note that we have not violated our assumption that paired ( x , ¯ x ) samples will not be provided while training the natural model—in this phase, the encoder ˜ f is frozen, and gradients can only flow into the linear probe.
Our comparisons for this experiment, evaluating our RMR pipeline against an identical architecture with an unfrozen P (equivalent to C-SWM [33]) is provided in Table 1.
For each of 20 random seeds, we feed identical batches to both models, hence we can perform a paired Wilcoxon test to assess the statistical significance of any observed differences on validation episodes.
The results are in line with our hypothesis: representations learnt by RMR are significantly better ( p < 0 . 05 ) on 15 out ofgames, significantly worse only on Pitfall!—and indistinguishable to C-SWM’s on others.
This is despite the fact their architectures are identical, indicating that the pre-trained abstract model induces stronger representations for predicting the underlying data factors.
As was the case for bouncing balls, we expose the algorithmic bottleneck here too; see Appendix C.
As a relevant initial baseline—and to emphasise the difficulty of our task—we also include in
Table 1 the performance of the latent embeddings extracted from a pre-trained Agent57 [49].
These embeddings are, perhaps unsurprisingly, substantially worse than both the RMR and C-SWM models.
As Agent57 was trained on a reward-maximising objective, its embeddings are likely to capture the controllable aspects of the input, while filtering out the environment’s background.
Abstract model transfer.
While the results above indicate that endowing a self-supervised Atari representation learner with knowledge of the underlying game’s RAM transitions yields stronger representations, one may still argue that this constitutes a form of “privileged information”.
This is due to the fact we knew upfront which game we were learning the representations for, and hence could leverage the specific RAM dynamics of this game.
In the final experiment, we study a more general setting: we are given access to RAM traces showing us how the Atari console manipulates its memory in response to player input, but we cannot guarantee these traces came from the same game that we are performing representation learning over.
Can we still effectively leverage this knowledge?
Specifically, we test abstract model transfer in the following way: first, we take a pre-trained abstract processor network P from one game (the “train game” ) and freeze it.
Then, using this processor, we perform the aforementioned natural pipeline training and testing over frames from another game (the “test game” ).
We then evaluate whether the recovered performance improves over the C-SWM model with unfrozen weights—once again using a paired one-sided Wilcoxon test over 20 seeds to ascertain statistical significance of any differences observed.
The final outcome of our experiment is hence a 24 × 24 matrix, indicating the quality of abstract model transfer from every game to every other game.
Table 1 corresponds to the “diagonal” entries of this matrix.
The results, presented in Figure 4, testify to the performance of RMR.
Representations learned by
RMR transfer better in 64 .
6% of the train/test game pairs, are indistinguishable from C-SWM in 33 .
7% of the game pairs and perform worse than C-SWM in only 1 .
7% of game pairs.
Therefore, in plentiful circumstances, the answer to our original question is positive : discovering a trace of Atari
RAM transitions of unknown origin can often be of high significance for representation learning from
Atari pixels, regardless of whether the underlying games match.
Qualitative analysis of transfer.
While we find this result interesting in and of itself, it also raises interesting follow-up questions.
Is representation learning on certain games more prone to being improved just by knowing anything about the Atari console?
Figure 4 certainly implies so: several games (such as Seaquest or Space Invaders) have “fully-green” columns, making them “universal recipients”.
Similarly, we may be interested about the “donor” properties of each game – to what extent are their RAM models useful across a broad range of test games?
We study both of the above questions by performing a hierarchical (complete-link) clustering of the rows and columns of the 24 × 24 matrix of transfer performances, to identify clusters of related donor and recipient games.
Both clusterings are marked in Figure 4 (on the sides of the matrix).
The analysis reveals several well-formed clusters, from which we are able to make some preliminary observations, based on the properties of the various games.
To name a few examples:
R i v e r
R a i d
B e r z e r k
P r i v a t e
E y e
M s .
P a c - M a n P i t
f a ll !
D e m o n
A tt a c k T e nn
i s
B r e a k o u t
Y a r s ' R e v e n g e
H .
E .
R .
O .
S e a q u e s t
Sp a c e I n v a d e r s
A s t e r o i d s
V i
d e o
P i n b a ll
B o w li n g
F r o s t b i t e
B a tt l e z
o n e
Q * B e r t
F r ee w a y
M o n t e z u m a ' s
R e v e n g e
V e n t
u
r e
P o n g
B o x i n g S k ii n g
[Table]
Asteroids
Freeway
Pitfall!
Frostbite
Private Eye
Tennis
Demon Attack
Bowling
Montezuma's Revenge
Yars' Revenge
Q*Bert
Space Invaders
Venture
Boxing
Pong
Skiing
Battlezone
Breakout
Video Pinball
Ms. Pac-Man
H.E.R.O.
Berzerk
River Raid
Seaquest
T r a i n
G a m e
[Table]
[Figure]
• The strongest recipients (e [Figure] g. Yars’ Revenge, H.E.R.O., Seaquest, Space Invaders and Asteroids) tend to include elements of “shooting” in their gameplay.
• Conversely, the weakest recipients (River Raid, Berzerk, Private Eye, Ms. Pac-Man and Pitfall!) are all games in which movement is generally unrestricted across most of the screen, indicating a larger range of possible coordinate values to model.
• Pong, Breakout, Battlezone and Skiing cluster closely in terms of donor properties—and they are all games in which movement is restricted to one axis only.
• Lastly, strong donors (Montezuma’s Revenge, Yars’ Revenge, Q*Bert and Venture) all feature massive, abrupt, changes to the game state (as they feature multiple rooms, for example).
This implies that they might generally have seen a more diverse set of transitions.
Further, on Yars’ Revenge, a massive laser features, which, conveniently, prints an RGB projection of the RAM itself on the frame.
Conclusions
We presented Reasoning-Modulated Representations (RMR), a novel approach for leveraging background algorithmic knowledge within a representation learning pipeline.
By encoding the underlying algorithmic priors as weights of a processor neural network, we alleviate requirements on alignment between abstract and natural inputs and protect our model against bottlenecks.
We believe that RMR paves the way to a novel class of algorithmic reasoning-inspired representations, with a high potential for transfer across tasks—a feat that has largely eluded deep reinforcement learning research
Acknowledgements
We would like to thank the developers of JAX [54] and Haiku [55].
Further, we are very thankful to
Adrià Puigdomènech Badia, Steven Kapturowski, Ankesh Anand, Richard Evans, Yulia Rubanova,
Alvaro Sanchez-Gonzalez and Bojan Vujatovi´c for their invaluable advice prior to submission
A Bouncing balls modelling setup
Abstract pipeline.
The f is a linear projection over the concatenation of inputs, outputting a 128long representation for each of the 10 balls in the input.
The P is a MPNN over the fully connected graph of the ball representations.
It is a 2-pass MPNN with a 3-layered ReLU-activated MLP as a message function, without the final layer activation, projecting to the same 128-dimensional space, per object.
Finally, g is a linear projection applied on each object representation of the output of P .
The model is MSE-supervised with ball position on the next step.
It is trained on a 8-core TPU for 10000 epochs, with a batch size of 512, and the Adam optimizer with the initial learning rate of 0.0001.
Natural pipeline.
¯ f is a Slot Attention model [40] on each input image, concatenating the images and passing them through a linear layer, outputting a 128-dimensional vector for each of the objects.
¯ g is a Broadcast Decoder [47] containing a sequence of 5 transposed convolutions and a linear layer mapping before calculating the reconstructions and their masks.
The model is MSE-supervised by pixel reconstruction (per-pixel MSE) over the next step image.
Both the RMR and the baseline are trained on a 8-core TPU for 1000 epochs, with a batch size of 512, with the Adam optimiser and the initial learning rate of 0.0001, all over 3 random seeds.
[Table]
B Atari abstract modelling setup and results
Our best processor network is a MPNN [51] over a fully connected graph [56] of RAM slots, which concatenates the action embedding to every node (as done in Kipf et al.
It uses three-layer
MLPs as message functions, with the ReLU activation applied after each hidden layer.
The entire model is trained for every game in isolation, over 48 distinct episodes of Agent57 experience.
We use the Adam SGD optimiser [57] with a batch size of 50 and a learning rate of 0 .
001 across all
Atari experiments.
To evaluate the benefits of message passing, we also compare our model to
Deep Sets [52], which is equivalent to our MPNN model—only it passes messages over the identity adjacency matrix.
Lastly, we evaluate the benefits of factorised latents by comparing our methods against a three-layer MLP applied on the flattened RAM state.
One immediate observation is that RAM updates in Atari are extremely sparse, with a copy baseline already being very strong for many games.
To prevent the model from having to repeatedly re-learn identity functions, we also make it predict masks of the shape M = B 128 , specifying which cells are to be overwritten by the model at this step.
This strategy, coupled with teacher forcing (as done by
Strathmann et al.
[16], Veliˇckovi´c et al.
[17]) yielded substantially stronger predictors.
We also use this observation to prevent over-inflating our prediction scores: we only display prediction accuracy over RAM slots with label entropy larger than 0 .
6 (as done by Anand et al.
The full results of training Atari RAM transition models, for the games studied in Anand et al.
[50], are provided in Table 2.
We evaluate both bit-level F 1 scores, as well as slot-level accuracy (for which all 8 bits need to be predicted correctly in order to count), over the remaining 48 Agent57 episodes as validation.
To the best of our knowledge, this is the first comprehensive feasibility study for learning
Atari RAM transition models.
C Rediscovering the algorithmic bottleneck
As mentioned in the main text body, one of the key reasons in favour of a high-dimensional algorithmic component is to avoid the algorithmic bottleneck , as first exposed by Deac et al.
In short, the performance guarantees of running classical algorithms rely on having the exactly correct inputs for them.
If there are any errors in the predictions of these (usually very low-dimensional) inputs, these errors may propagate to the algorithmic computations and yield suboptimal results.
Further, there is no room for any kind of fallback if such an event occurs.
In contrast, the high-dimensional neural processors like the ones we study here are not vulnerable to bottleneck effects: if any dimensions of the latent state are poorly predicted, the other components of it could step in and compensate for this.
Further, we can easily support skip connections in the case where the algorithm is not fully descriptive of the problem we’re solving.
In this section, we reaffirm the bottleneck effect for both Atari and bouncing ball experiments by providing additional sets of ablations on the processor network’s latent size.
We ablate various RMR processor network architectures, for dim z ∈ { 2 , 4 , 8 , 16 , 32 , 64 } , but leaving all other components and operations unchanged.
The results of this ablation for the Atari representation learning setting are provided in Figure 5.
It can be clearly observed that, as we reduce the size of the latents, this typically induces a performance regression in the downstream bit F 1 scores.
This indicates the algorithmic bottleneck effect.
On the bouncing balls task, we observe the algorithmic bottleneck as well, with more pronounced effects.
Namely, for all latent sizes 32 and under, the validation MSE shoots up even though the training MSE keeps improving.
Ultimately, we also attempted using an Interaction Network [7] as a bottlenecked RMR processor which requires projecting on to ¯ x rather than z , which exhibited exactly the same behaviour, at a larger scale.
The IN processor achieved a final validation MSE of 341 .
40 ± 5 .
60 ( × 10 − 4 ) .
This is roughly 43 × worse than the non-bottlenecked RMR.
D On the weak acceptor properties of Battlezone
Out of all the Atari games studied in our work, Battlezone could been singled out as the least “receptive” to RMR processors—with only four games successfully donating their RAM representations to its pixel based encoder (Figure 4).
We set out to study why this effect took place.
Upon inspection of the game’s dynamics 2 , we determined that Battlezone has certain properties that make representation learning uniquely challenging and somewhat decoupled from the underlying console computation.
Namely, Battlezone is the only game in our dataset that is played in the “first-person” perspective.
Therefore, from the point of view of the pixel inputs, it may seem as if the player is always in the same place, and we would expect the mechanics and the way of thinking about the ’avatar’ to be substantially different from all other Atari games considered.
E On the data distribution and setup used for training the processor
In many cases, while an algorithmic prior may be known, generative aspects of the relevant abstract inputs for the natural task could be unknown.
For example, it may be known that the natural task could benefit from a sorting subroutine, but it may not be known upfront how many objects will need to be sorted.
When such details are unknown, it may still be possible to fall back to abstract inputs sampled from some sensible generic random distribution—so long as the processor network is trained in a way that promotes extrapolation.
For a recent theoretical treatment of OOD generalisation in algorithmic reasoners, we refer the reader to Xu et al.
Further, as observed by Deac et al.
[8] in the case of implicit planning, even generic random abstract distributions can promote useful transfer to noisy pixel-based acting settings such as Atari.
Lastly, it is important to ensure that, in the abstract pipeline, the processor network P carries the brunt of the computational burden; otherwise, the reasoning task may be partially captured in either f or g , and not left to P ’s weights.
In our work, we generally promote such behaviour by keeping f and g to be only linear layers; but even in settings where this is not appropriate, we recommend taking care to not overpower the abstract encoder and decoder.
F Atari abstract model equations
In this appendix, we provide a “bird’s eye” view of the modelling steps taken by our abstract Atari pipeline, aiming to support future implementations of the RMR blueprint.
We will readily re-use the notation from the main text for the various components.
Firstly, the abstract encoder f is applied on the relevant Atari RAM representations, ¯ x , augmented by a one-hot representation which is aiming to provide a generic embedding of the semantics of each
RAM slot.
f is implemented as a linear layer, hence:
[Equation]
where W f , U f , b f are learnable weights, and o ∈ B 128 × 128 is a one-hot encoding s.t.
o
=
I 128 .
In a separate pipeline (officially part of the processor network), the performed actions are also encoded using a linear action encoder:
[Equation]
where a is a one-hot encoded action representation.
Then, the processor network GNN is called to update these latents, and a sum-based skip connection is employed to promote a model-free path:
[Equation]
Here, the processor network P is implemented as a standard message passing neural network [51] over a fully connected graph.
Equations of such a P are commonly exposed in e.g. Veli
ˇ ckovi ´ c et al.
Lastly, the relevant decoder networks predict two properties: a mask which signifies which RAM slots have been changed as a result of applying a , and the updated states ¯ y .
[Equation]
[Equation] Here, σ is the logistic sigmoid activation, ⊙ is the elementwise product, and I is the indicator function, which thresholds the mask.
While this thresholding is non-differentiable, we note that the mask values can be directly supervised from known trajectories, and at training time, teacher forcing can be applied—slotting ground-truth masks in place of the indicator function.