R ECURRENT I NDEPENDENT M ECHANISMS
Anonymous authors
Paper under double-blind review
A BSTRACT
We explore the hypothesis that learning modular structures which reﬂect the dynamics of the environment can lead to better generalization and robustness to changes that only affect a few of the underlying causes.
We propose Recurrent
Independent Mechanisms (RIMs), a new recurrent architecture in which multiple groups of recurrent cells operate with nearly independent transition dynamics, communicate only sparingly through the bottleneck of attention, and compete with each other so they are updated only at time steps where they are most relevant.
We show that this leads to specialization amongst the RIMs, which in turn allows for remarkably improved generalization on tasks where some factors of variation differ systematically between training and evaluation.
I NDEPENDENT M ECHANISMS
Physical processes in the world often have a modular structure which human cognition appears to exploit, with complexity emerging through combinations of simpler subsystems.
Machine learning seeks to uncover and use regularities in the physical world.
Although these regularities manifest themselves as statistical dependencies, they are ultimately due to dynamic processes governed by causal physical phenomena.
These processes are mostly evolving independently and only interact sparsely.
For instance, we can model the motion of two balls as separate independent mechanisms even though they are both gravitationally coupled to Earth as well as (weakly) to each other.
Only occasionally will they strongly interact via collisions.
The notion of independent or autonomous mechanisms has been inﬂuential in the ﬁeld of causal inference.
A complex generative model, temporal or not, can be thought of as the composition of independent mechanisms or “causal” modules.
In the causality community, this is often considered a prerequisite for being able to perform localized interventions upon variables determined by such models (Pearl, 2009).
It has been argued that the individual modules tend to remain robust or invariant even as other modules change, e.g., in the case of distribution shift (Schölkopf et al., 2012; Peters et al., 2017).
This independence is not between the random variables being processed but between the description or parametrization of the mechanisms: learning about one should not tell us anything about another, and adapting one should not require also adapting another.
One may hypothesize that if a brain is able to solve multiple problems beyond a single i.i.d.
(independent and identically distributed) task
, they may exploit the existence of this kind of structure by learning independent mechanisms that can ﬂexibly be reused, composed and re-purposed.
In the dynamic setting, we think of an overall system being assayed as composed of a number of fairly independent subsystems that evolve over time, responding to forces and interventions.
An agent needs not devote equal attention to all subsystems at all times: only those aspects that signiﬁcantly interact need to be considered jointly when deciding or planning (Bengio, 2017).
Such sparse interactions can reduce the difﬁculty of learning since few interactions need to be considered at a time, reducing unnecessary interference when a subsystem is adapted.
Models learned this way may better capture the compositional generative (or causal) structure of the world, and thus better generalize across tasks where a (small) subset of mechanisms change while most of them remain invariant (Simon, 1991;
Peters et al., 2017; Parascandolo et al.,
2018).The central question motivating our work is how a gradient-based deep learning approach can discover a representation of high-level variables which favour forming independent but sparsely interacting recurrent mechanisms in order to beneﬁt from the modularity and independent mechanisms assumption.
Why do Models Succeed or Fail in Capturing Independent Mechanisms?
While universal approximation theorems apply in the limit of large i.i.d.
data sets, we are interested in the question of whether models can learn independent mechanisms from ﬁnite data in possibly changing environments, and how to implement suitable inductive biases.
As the simplest case, we can consider training an RNN consisting of k completely independent mechanisms which operate on distinct time steps.
How difﬁcult would it be for an RNN (whether vanilla or LSTM or GRU) to correctly model that the true distribution has completely independent processes?
For the hidden states to truly compartmentalize these different processes, a fraction k − 1 k of the connections would need to be set to exactly zero weight.
This fraction approaches 100% as k approaches inﬁnity.
When sample complexity or out-of-distribution generalization matter, we argue that having an inductive bias which favors this form of modularity and dynamic recombination could be greatly advantageous, compared to static fully connected monolithic architectures.
The central question motivating our work is how a gradient-based deep learning approach can discover a representation of high-level variables which favour forming independent but sparsely interacting recurrent mechanisms in order to beneﬁt from the modularity and independent mechanisms assumption.
This assumption is linked to the decomposition of the joint distribution of the high-level variables into independent causal mechanisms: instead of interpreting disentangling as complete marginal independence of the high-level variables (Higgins et al., 2016; Burgess et al., 2018), we believe that these variables, often named with words in language, have highly structured dependencies corresponding to a sparse factor graph.
RIM S WITH S PARSE I NTERACTIONS
Our approach to modelling a dynamical system of interest divides the overall model into k small subsystems (or modules), each of which is recurrent in order to be able to capture the dynamics in the observed sequences.
We refer to these subsystems as Recurrent Independent Mechanisms (RIMs) , where each RIM has distinct functions that are learned automatically from data 1 .
We refer to RIM k at time step t as having vector-valued state h t,k , where t = 1 , . .
, T .
Each RIM has parameters θ k , which are shared across all time steps.
At a high level (see Fig. 1), we want each RIM to have its own independent dynamics operating by default, and occasionally to interact with other relevant RIMs and selected elements of the encoded input.
The total number of parameters can be kept small since RIMs can specialize on simple sub-problems, similar to Parascandolo et al.
(2018), and operate on few key/value variables at a time selected using an attention mechanism, as suggested by the inductive bias from Bengio (2017).
This specialization and modularization not only has computational and statistical advantages (Baum & Haussler, 1989), but also prevents individual RIMs from dominating the computation and thus facilitates factorizing the computation into easy to recombine but simpler elements.
We expect this to lead to more robust systems than training one big homogeneous system (Schmidhuber, 2018).
Moreover, modularity and the independent mechanisms hypothesis (Peters et al., 2017; Bengio et al., 2019) also has the desirable implication that a RIM should maintain its own independent functionality even as other RIMs are changed.
A more detailed account of the desiderata for the model is given in
Appendix A.
2. K EY -V ALUE A TTENTION TO P ROCESS S ETS OF N AMED I NTERCHANGEABLE V ARIABLES
Each RIM should be activated and updated when the input is relevant to it.
We thus utilize competition to allocate representational and computational resources, using an attention mechanism which selects and then activates only a subset of the RIMs for each time step.
As argued by Parascandolo et al.
(2018), this tends to produce independence among learned mechanisms, provided the training data has been generated by a set of independent physical mechanisms.
In contrast to Parascandolo et al.
(2018), we use an attention mechanism for this purpose.
The introduction of content-based soft-attention mechanisms (Bahdanau et al., 2014) has opened the door to neural networks which operate on sets of typed interchangeable objects .
This idea has been remarkably successful and widely applied to most recent Transformer-style multi-head dot product self attention models (Vaswani et al., 2017;
Santoro et al., 2018), achieving new state-of-the-art results in many tasks.
Soft-attention uses the product of a query (or read key ) represented as a matrix Q of dimensionality N r × d , with d the dimension of each key, with a set of N o objects each associated with a key (or write-key ) as a row in matrix K T ( N o × d ), and after normalization with a softmax yields outputs in the convex hull of the values (or write-values ) V i (row i of matrix V ).
The result is
[Equation]
where the softmax is applied to each row of its argument matrix, yielding a set of convex weights.
As a result, one obtains a convex combination of the values in the rows of V .
If the attention is focused on one element for a particular row (i.e., the softmax is saturated), this simply selects one of the objects and copies its value to row j of the result.
Note that the d dimensions in the key can be split into heads which then have their own attention matrix and write values computed separately.
When the inputs and outputs of each RIM are a set of objects or entities (each associated with a key and value vector), the RIM processing becomes a generic object-processing machine which can operate on subsymbolic “variables” in a sense analogous to variables in a programming language: as interchangeable arguments of functions, albeit with a distributed representation both for they name or type and for their value.
Because each object has a key embedding (which one can understand both as a name and as a type), the same RIM processing can be applied to any variable which ﬁts an expected "distributed type" (speciﬁed by a query vector).
Each attention head then corresponds to a typed argument of the function computed by the RIM.
When the key of an object matches the query of head k , it can be used as the k -th input vector argument for the RIM.
Whereas in regular neural networks (without attention) neurons operate on ﬁxed variables (the neurons which are feeding them from the previous layer), the key-value attention mechanisms make it possible to select on the ﬂy which variable instance (i.e. which entity or object) is going to be used as input for each of the arguments of the RIM dynamics, with a different set of query embeddings for each RIM head.
These inputs can come from the external input or from the output of other RIMs.
So, if the individual RIMs can represent these functions with typed arguments , then they can bind to whatever input is currently available and best suited according to its attention score: the “input attention” mechanism would look at the candidate input object’s key and evaluate if its “type” matches with what this RIM expects (speciﬁed with the corresponding query).
2. S ELECTIVE A CTIVATION OF RIM S AS A FORM OF T OP -D OWN M ODULATION
The proposed model learns to dynamically select those RIMs for which the current input is relevant.
RIMs are triggered as a result of interaction between the current state of the RIM and input information coming from the environment.
At each step, we select the top- k A (out of k T ) RIMs in terms of their attention score for the real input.
Intuitively, the RIMs must compete on each step to read from the input, and only the RIMs that win this competition will be able to read from the input and have their state updated.
In our use of key-value attention, the queries come from the RIMs, while the keys and values come from the current input.
This differs from the mechanics of Vaswani et al.
Santoro et al.
(2018), with the modiﬁcation that the parameters of the attention mechanism itself are separate for each RIM rather than produced on the input side as in Transformers.
The input attention for a particular RIM is described as follows.
The input x t at time t is seen as a set of elements, structured as rows of a matrix.
We ﬁrst concatenate a row full of zeros, to obtain
[Equation]
As before, linear transformations are used to construct keys ( K = XW e , one per input element and for the null element), values ( V = XW v , again one per element), and queries ( Q =
h t
W qk , one per
RIM attention head).
W v is a simple matrix mapping from an input element to the corresponding value vector for the weighted attention and W e is similarly a weight matrix which maps the input to the keys.
W qk is a per-RIM weight matrix which maps from the RIM’s hidden state to its queries.
⊕ refers to the row-level concatenation operator.
The attention thus is
[Equation]
θ
[Equation]
Based on the softmax values in (2), we select the top k A RIMs (out of the total K RIMs) to be activated for each step, which have the least attention on the null input (and thus put the highest attention on the input), and we call this set S t .
Since the queries depend on the state of the RIMs, this enables individual RIMs to attend only to the part of the input that is relevant for that particular RIM, thus enabling selective attention based on a top-down attention process (see.
Fig 1).
In practice, we use multiheaded attention, and multi-headed attention doesn’t change the essential computation, but when we do use it for input-attention we compute RIM activation by averaging the attention scores over the heads.
For spatially structure input: All datasets we considered are temporal, yet there is a distinction between whether the input on each time step is highly structured (such as a video) or not (such as language modeling, where each step has a word or character).
In the former case, we can get further improvements by making the activation of RIMs not just sparse across time but also sparse across the (spatial) structure.
The input x t at time t can be seen as an output of the encoder parameterized by a neural network (for ex. CNN in case of visual observations) i.e., X = CNN ( x t ) .
As before, linear transformations are used to construct position-speciﬁc input keys ( K = XW e ), position-speciﬁc values ( V = XW v ), and RIM speciﬁc queries ( Q = h t
W qk , one per RIM attention head).
The attention thus is
[Equation]
In order for different RIMs to specialize on different spatial regions, we can use position-speciﬁc competition among the different RIMs.
The contents of the attended positions are combined yielding a RIM-speciﬁc input.
As before based on the softmax values in (3), we can select the top k A RIMs (out of the total k T RIMs) to be activated for each spatial position, which have the highest attention on that spatial position.
2. I NDEPENDENT RIM D YNAMICS
Now, consider the default transition dynamics which we apply for each RIM independently and during which no information passes between RIMs.
We use ˜ h for the hidden state after the independent dynamics are applied.
The hidden states of RIMs which are not activated (we refer to the activated set as S t ) remain unchanged, acting like untouched memory elements, i.e., h t +1 ,
k = h t,k ∀ k
[Equation]
∈
S t .
Note that the gradient still ﬂows through a RIM on a step where it is not activated.
For the
RIMs that are activated, we run a per-RIM independent transition dynamics.
The form of this is somewhat ﬂexible, but we opted to use either a GRU (Chung et al., 2015) or an LSTM (Hochreiter & Schmidhuber, 1997).
We generically refer to these independent transition dynamics as D k , and we emphasize that each RIM has its own separate parameters.
Aside from being RIM-speciﬁc, the internal operation of the LSTM and GRU remain unchanged, and active RIMs are updated by
[Equation]
as a function of the attention mechanism A ( in ) k applied on the current input, described in the previous sub-section.
2. C OMMUNICATION BETWEEN RIM S
Although the RIMs operate independently by default, the attention mechanism allows sharing of information among the RIMs.
Speciﬁcally, we allow the activated RIMs to read from all other RIMs (activated or not).
The intuition behind this is that non-activated RIMs are not related to the current input, so their value needs not change.
However they may still store contextual information relevant for activated RIMs later on.
For this communication between RIMs, we use a residual connection as in Santoro et al.
(2018) to prevent vanishing or exploding gradients over long sequences.
Using parameters θ ( c ) k
= (
[Equation]
qk , ˜ W ek , ˜ W vk ) , we employ
[Equation]
We note that we can also consider sparsity in the communication attention such that a particular
RIM only attends to sparse sub-set of other RIMs, and this sparsity is orthogonal to the kind used in input attention.
In order to make the communication attention sparse, we can still use the same top- k attention.
Number of Parameters.
RIMs can be used as a drop-in replacement for an LSTM/GRU layer.
There is a subtlety that must be considered for successful integration.
If the total size of the hidden state is kept the same, integrating RIMs drastically reduces the total number of recurrent parameters in the model (because of having a block-sparse structure).
RIMs also adds new parameters to the model through the addition of the attention mechanisms although these are rather in small number.
Multiple Heads: Analogously to Vaswani et al.
; Santoro et al.
(2018), we use multiple heads both for communication between RIMs as well as input attention (as in Sec 2.2) by producing different sets of queries, keys, and values to compute a linear transformation for each head (different heads have different parameters), and then applying the attention operator for each head separately in order to select conditioning inputs for the RIMs.
R ELATED W ORK
Neural Turing Machine (NTM) and Relational Memory Core (RMC): the NTM (Graves et al., 2014a) updates independent memory cells using an attention mechanism to perform targeted read and write operations.
RIMs share a key idea with NTMs: that input information should only impact a sparse subset of the memory by default, while keeping most of the memory unaltered.
RMC (Santoro et al., 2018) uses a multi-head attention mechanism to share information between multiple memory elements.
We encourage the RIMs to remain separate as much as possible, whereas Santoro et al.
(2018) allow information between elements to ﬂow on each step in an unsconstrained way.
Instead, each RIM has its own default dynamics, while in RMC, all the processes interact with each other.
Separate Recurrent Models: EntNet (Henaff et al., 2016) and IndRNN (Li et al., 2018) can be viewed as a set of separate recurrent models.
In IndRNN, each recurrent unit has completely independent dynamics, whereas EntNet uses an independent gate for writing to each memory slot.
RIMs use different recurrent models (with separate parameters), but we allow the RIMs to communicate with each other sparingly using an attention mechanism.
Modularity and Neural Networks :
A network can be composed of several modules, each meant to perform a distinct function, and hence can be seen as a combination of experts (Jacobs et al., 1991; Bottou & Gallinari, 1991; Ronco et al., 1997;
Reed & De Freitas, 2015; Andreas et al., 2016;
Parascandolo et al., 2018; Rosenbaum et al., 2017; Fernando et al., 2017; Shazeer et al., 2017; Kirsch et al., 2018; Rosenbaum et al., 2019) routing information through a gated activation of modules.
These works generally assume that only a single expert is active at a particular time step.
In the proposed method, multiple RIMs can be active, interact and share information.
Computation on demand: There are various architectures (El Hihi & Bengio, 1996; Koutnik et al., 2014; Chung et al., 2016; Neil et al., 2016; Jernite et al., 2016; Krueger et al., 2016) where parts of the RNN’s hidden state are kept dormant at times.
The major differences to our architecture are that (a) we modularize the dynamics of recurrent cells (using RIMs), and (b) we also control the inputs of each module (using transformer style attention), while many previous gating methods did not control the inputs of each module, but only whether they should be executed or not.
E XPERIMENTS
The main goal of our experiments is to show that the use of RIMs improves generalization across changing environments and/or in modular tasks, and to explore how it does so.
Our goal is not to outperform highly optimized baselines; rather, we want to show the versatility of our approach by applying it to a range of diverse tasks, focusing on tasks that involve a changing environment.
We organize our results by the capabilities they illustrate: we address generalization based on temporal patterns, based on objects, and ﬁnally consider settings where both of these occur together.
4. RIM S IMPROVE GENERALIZATION BY SPECIALIZING OVER TEMPORAL PATTERNS
We ﬁrst show that when RIMs are presented with sequences containing distinct and generally independent temporal patterns, they are able to specialize so that different RIMs are activated on different patterns.
RIMs generalize well when we modify a subset of the patterns (especially those unrelated to the class label) while most recurrent models fail to generalize well to these variations.
Copying Task:
First we turn our attention to the task of receiving a short sequence of characters, then receiving blank inputs for a large number of steps, and then being asked to reproduce the original sequence.
We can think of this as consisting of two temporal patterns which are independent: one where the sequence is received and another “dormant” pattern where no input is provided.
As an example of out-of-distribution generalization, we ﬁnd that using RIMs, we can extend the length of this dormant phase from 50 during training to 200 during testing and retain perfect performance (Table 1), whereas baseline methods including LSTM, NTM, and RMC substantially degrade.
In addition, we ﬁnd that this result is robust to the number of RIMs used as well as to the number of
RIMs activated per-step.
Our ablation results (Appendix D.1) show that all major components of the
RIMs model are necessary to achieve this generalization.
This is evidence that RIMs can specialize over distinct patterns in the data and improve generalization to settings where these patterns change.
Sequential MNIST Resolution Task: RIMs are motivated by the hypothesis that generalization performance can beneﬁt from modules which only activate on relevant parts of the sequence.
For further evidence that RIMs can achieve this out-of-distribution, we consider the task of classifying
MNIST digits as sequences of pixels (Krueger et al., 2016) and assay generalization to images of resolutions different from those seen during training.
Our intuition is that the RIMs model should have distinct subsets of the RIMs activated for pixels with the digit and empty pixels.
RIMs should generalize better to higher resolutions by keeping RIMs dormant which store pixel information over empty regions of the image.
Results: Table 1 shows the result of the proposed model on the Sequential MNIST Resolution Task.
If the train and test sequence lengths agree, both models achieve comparable test set performance.
However, RIMs model is relatively robust to changing the sequence length (by changing the image resolution), whereas the LSTM performance degraded more severely.
This can be seen as a more involved analogue of the copying task, as MNIST digits contain large empty regions.
It is essential that the model be able to store information and pass gradients through these regions.
The RIMs outperform strong baselines such as Transformers, EntNet, RMC, and (DNC) (Graves et al., 2016).
[Table]
4. RIM S LEARN TO SPECIALIZE OVER OBJECTS AND GENERALIZE BETWEEN THEM
We have shown that RIMs can specialize over temporal patterns.
We now turn our attention to assaying whether RIMs can specialize to objects, and show improved generalization to cases where we add or remove objects at test time.
Bouncing Balls Environment: We consider a synthetic “bouncing balls” task in which multiple balls (of different masses and sizes) move using basic Newtonian physics (Van Steenkiste et al., 2018).
What makes this task particularly suited to RIMs is that the balls move independently most of the time, except when they collide.
During training, we predict the next frame at each time step using teacher forcing (Williams & Zipser, 1989).
We can then use this model to generate multi-step rollouts.
As a preliminary experiment, we train on sequences of length 51 (the previous standard), using a binary cross entropy loss when predicting the next frame.
We consider LSTMs as baselines.
We then produce rollouts, ﬁnding that RIMs are better able to predict future motion (Figure 3)
We take this further by evaluating RIMs on environments where the test setup is different from the training setup.
First we consider training with 4 balls and evaluating on an environment with 6balls.
Second, we consider training with 6-8 balls and evaluating with just 4 balls.
Robustness in these settings requires a degree of invariance w.r.t.
the number of balls.
In addition, we consider a task where we train on 4 balls and then evaluate on sequences where part the visual space is occluded by a “curtain.”
This allows us to assess the ability of balls to be tracked (or remembered) through the occluding region.
Our experimental results on these generalization tasks (Figure 3) show that RIMs substantially improve over an LSTM baseline.
We found that increasing the capacity of the LSTM from 256 to 512 units did not substantially change the performance gap, suggesting that the improvement from RIMs is not primarily related to capacity.
Environment with Novel Distractors: We next consider an object-picking reinforcement learning task from BabyAI (Chevalier-Boisvert et al., 2018) in which an agent must retrieve a speciﬁc object in the presence of distractors.
We use a partially observed formulation of the task, where the agent only sees a small number of squares ahead of it.
These tasks are difﬁcult to solve (Chevalier-Boisvert et al., 2018) with standard RL algorithms, due to (1) the partial observability of the environment and (2) the sparsity of the reward, given that the agent receives a reward only after reaching the goal.
During evaluation, we introduce new distractors to the environment which were not observed during training.
Figure 4 shows that RIMs outperform
LSTMs on this task (details in appendix).
When evaluating with known distractors, the RIM model achieves perfect performance while the LSTM struggles.
When evaluating in an environment with novel unseen distractors the RIM doesn’t achieve perfect performance but strongly outperforms the LSTM.
An LSTM with a single memory ﬂow may struggle to keep the distracting elements separate from elements which are necessary for the task, while the RIMs model uses attention to control which RIMs receive information at each step as well as what information they receive (as a function of their hidden state).
This "top-down" attention results in a diminished representation of the distractor, not only enhancing the target visual information, but also suppressing irrelevant information.
4. RIM S IMPROVE GENERALIZATION IN COMPLEX ENVIRONMENTS
We have investigated how RIMs use specialization to improve generalization to changing important factors of variation in the data.
While these improvements have often been striking, it raises a question: what factors of variation should be changed between training and evaluation?
One setting where factors of variation change naturally is in reinforcement learning, as the data received from an environment changes as the agent learns and improves.
We conjecture that when applied to reinforcement learning, an agent using RIMs may be able to learn faster as its specialization leads to improved generalization to previously unseen aspects of the environment.
To investigate this we use an RL agent trained using Proximal Policy Optimization (PPO)
(Schulman et al., 2017) with a recurrent network producing the policy.
We employ an LSTM as a baseline, and compare results to the RIMs architecture.
This was a simple drop-in replacement and did not require changing any of the hyperparameters for PPO.
We experiment on the whole suite of Atari games and ﬁnd that simply replacing the LSTM with RIMs greatly improves performance (Figure 5).
There is also an intriguing connection between the selective activation in RIMs and the concept of affordances from cognitive psychology (Gibson, 1977; Cisek & Kalaska, 2010).
To perform well in environments with a dynamic combination of risks and opportunities, an agent should be ready to adapt immediately, executing actions which are at least partially prepared.
This suggests agents should process sensory information in a contextual manner, building representations of potential actions that the environment currently affords.
For instance, in Demon Attack, one of the games where RIMs exhibit strong performance gains, the agent must quickly choose between targeting distant aliens to maximize points and avoiding ﬁre from close-by aliens to avoid destruction (indeed both types of aliens are always present, but which is relevant depends on the player’s position).
We hypothesize that in cases like this, selective activation of RIMs allows the agent to rapidly adapt its information processing to the types of actions relevant to the current context.
4. D ISCUSSION AND A BLATIONS
Sparse Activation is necessary, but works for a wide range of hyperparameters: On the copying task, we tried a wide variety of sparsity levels for different numbers of RIMs, and found that using a sparsity level between 30% to 70% performed optimally, suggesting that the sparsity hyperparameter is fairly ﬂexible (refer to Table 4, 5 in appendix).
On Atari we found that using k A = 5 slightly improved over results compared with k A = 4 , but both had similar performance across the vast majority of games.
Input-attention is necessary: We study the scenario where we remove the input attention process (i.e the top-down competition between different RIMs) but still allow the RIMs ot communicate with attention.
We found that this degraded results substantially on Atari but still outperformed the LSTM baseline.
See (Figure 20) in appendix for more details.
Communication between RIMs improves performance:
For copying and sequential MNIST, we performed an ablation where we remove the communication between RIMs and varied the number of RIMs and the number of activated RIMs (Refer to Table 4 in appendix.).
We found that the communication between RIMs is essential for good performance.
C ONCLUSION
Many systems of interest comprise multiple dynamical processes that operate relatively independently and only occasionally have meaningful interactions.
Despite this, most machine learning models employ the opposite inductive bias, i.e., that all processes interact.
This can lead to poor generalization and lack of robustness to changing task distributions.
We have proposed a new architecture, Recurrent
Independent Mechanisms (RIMs), in which we learn multiple recurrent modules that are independent by default, but interact sparingly.
For the purposes of this paper, we note that the notion of RIMs is not limited to the particular architecture employed here.
The latter is used as a vehicle to assay and validate our overall hypothesis (cf.
Appendix A), but better architectures for the RIMs model can likely be found
Appendix
Contents
B
Work
C Model Setup Details and Hyperparameters
C.1 RIMs Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
C.2 Detailed Model Hyperparameters . . . . . . . . . . . . . . . . . . . . . . . . .
C.3 Other Architectural Changes that we Explored . .
D Experiment Details
D.1 Effect of Varying Number and Active RIMs on Copying Task . . . . . . . . . .
D.2 Effect of Varying Number and Active RIMs on Adding Task . . . . . . . . . . .
D.3 Sequential MNIST Resolution Task . . . . . . . . . . . . . . . . . . . . . . . .
D.4 Bouncing Ball Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . .
D.5 Video Prediction from Crops . . . . . . . . . . . . . . . . . . . . . . . . . . .
D.6 Environment with Novel Distractors . . . . . . . . . . . . . . . . . . . . . . . .
D.7 MiniGrid Environments for OpenAI Gym . . . . . . . . . . . . . . . . . . . . .
D.8 Atari . . .
E Additional Experiments
E.
Learning
Robustness
Noise in
[Table] [Table]
Transfer on Atari
[Table] [Table]
[Table] [Table]
A D ESIDERATA FOR R ECURRENT I NDEPENDENT M ECHANISMS
We have laid out a case for building models composed of modules which by default operate independently and can interact in a limited manner.
Accordingly, our approach to modelling the dynamics of the world starts by dividing the overall model into small subsystems (or modules), referred to as Recurrent Independent Mechanisms (RIMs) , with distinct functions learned automatically from data.
Our model encourages sparse interaction, i.e., we want most RIMs to operate independently and follow their default dynamics most of the time, only rarely sharing information.
Below, we lay out desiderata for modules to capture modular dynamics with sparse interactions.
Competitive Mechanisms: Inspired by the observations in the main paper, we propose that RIMs utilize competition to allocate representational and computational resources.
As argued by (Parascandolo et al., 2018), this tends to produce independence among learned mechanisms if the training data has been generated by independent physical mechanisms.
Top Down Attention:
The points mentioned in Section 2 in principle pertain to synthetic and natural intelligent systems alike.
Hence, it is not surprising that they also appear in neuroscience.
For instance, suppose we are looking for a particular object in a large scene, using limited processing capacity.
The biased competition theory of selective attention conceptualizes basic ﬁndings of experimental psychology and neuroscience (Desimone & Duncan, 1995): our capacity of parallel processing of and reasoning with high-level concepts is limited, and many brain systems representing visual information use competition to allocate resources.
Competitive interactions among multiple objects occur automatically and operate in parallel across the visual ﬁeld.
Second, the principle of selectivity amounts to the idea that a perceiver has the ability to ﬁlter out unwanted information and selectively process the rest of the information.
Third, top-down bias originating from higher brain areas enables us to selectively devote resources to input information that may be of particular interest or relevance.
This may be accomplished by units matching the internal model of an object or process of interest being pre-activated and thus gaining an advantage during the competition of brain mechanisms.
Sparse Information Flow: Each RIM’s dynamics should only be affected by RIMs which are deemed relevant.
The fundamental challenge is centered around establishing sensible communication between modules.
In the presence of noisy or distracting information, a large subset of RIMs should stay dormant, and not be affected by the noise.
This way, training an ensemble of these RIMs can be more robust to out-of-distribution or distractor observations than training one big homogeneous neural network (Schmidhuber, 2018).
Modular Computation Flow and Modular Parameterization: Each RIM should have its own dynamics operating by default , in the absence of interaction with other RIMs.
The total number of parameters (i.e. weights) can be reduced since the RIMs can specialize on simple sub-problems, similar to (Parascandolo et al., 2018).
This can speed up computation and improve the generalisation ability of the system (Baum & Haussler, 1989).
The individuals RIMs in the ensemble should be simple also to prevent individual RIMs from dominating and modelling complex, composite mechanisms.
We refer to a parameterization as modular if most parameters are associated to individuals RIMs only.
This has the desirable property that a RIM should maintain its own independent functionality even as other RIMs are changed (due to its behavior being determined by its own self-contained parameters).
B E XTENDED R ELATED W ORK
[Table]
The present section provides further details on related work, thus extending Section 3.
Neural Turing Machine (NTM) .
The NTM (Graves et al., 2014a) has a Turing machine inspired memory with a sequence of independent memory cells, and uses an attention mechanism to move heads over the cells while performing targeted read and write operations.
This shares a key idea with RIMs: that input information should only impact a sparse subset of the memory by default, while keeping most of the memory unaltered.
The RIM model introduces the idea that each RIM has its own independent dynamics, whereas the mechanism for updating memory cells update is shared.
Relational RNN .
The Relational Models paper (Santoro et al., 2018) is based on the idea of using a multi-head attention mechanism to share information between multiple parts of memory.
It is related to our idea but a key difference is that we encourage the RIMs to remain separate as much as possible, whereas (Santoro et al., 2018) allows information between the parts to ﬂow on each step (in effect making the part distribution only relevant to a particular step).
Additionally, RIMs has the notion of each RIM having its own independent transition dynamics which operate by default, whereas the Relational RNN only does computation and updating of the memory using attention.
Sparse Attentive Backtracking (SAB) .
The SAB architecture (Ke et al., 2018) explores RNNs with self- attention across time steps as well as variants where the attention is sparse in the forward pass and where the gradient is sparse in the backward pass.
It shares the motivation of using sparse attention to keep different pieces of information separated, but differs
Independently Recurrent Neural Network (IndRNN) .
The IndRNN (Li et al., 2018) replaces the full transi- tion matrix in a vanilla RNN (between time steps) to a diagonal transition weight matrix.
In other words, each recurrent unit has completely independent dynamics.
Intriguingly they show that this gives much ﬁner control over the gating of information, and allows for such an RNN to learn long-term dependencies without vanishing or exploding gradients.
Analysis of the gradients shows that having smaller recurrent transition matrices mitigates the vanishing and exploding gradient issue.
This may provide further explanation for why RIMs perform well on long sequences.
Consciousness Prior (Bengio, 2017):
This is based on the inductive bias of a sparse graphical model describing the interactions between high-level variables, each factor involving few variables and capaturing an independent mechanism, and using attention to select only a subset of high-level variables to interact together at any particular time during inference.
This motivates in RIMs the use of modules (corresponding to factors) which dynamically select which variables (instances) they apply to, with modules activated sparsely (only those factors which need to interact) and communicating sparsely (only a few variables, i.e., heads, involved for each).
Our paper thus helps to validate the inductive bias of the consciousness prior.
Recurrent Entity Networks : EnTNet (Henaff et al., 2016) can be viewed as a set of separate recurrent models whose hidden states store the memory slots.
These hidden states are either ﬁxed by the gates, or modiﬁed through a simple RNN-style update.
Moreover, EntNet uses an independent gate for writing to each memory slot.
Our work is related in the sense that we also have different recurrent models (i.e.,RIMs, though each RIM has different parameters), but we allow the RIMs to communicate with each other sparingly using an attention mechanism.
Capsules and Dynamic Routing: EM Capsules (Hinton et al., 2018) and the preceding Dynamic Capsules (Sabour et al., 2017) use the poses of parts and learned part → object relationships to vote for the poses of objects.
When multiple parts cast very similar votes, the object is assumed to be present, which is facilitated by an interactive inference (routing) algorithm.
Relational Graph Based Methods: Recent graph-based architectures have studied combinatorial generalization in the context of modeling dynamical systems like physics simulation, multi-object scenes, and motion-capture data, and multiagent systems (Scarselli et al., 2008;
Bronstein et al., 2017; Watters et al., 2017; Raposo et al., 2017; Santoro et al., 2017; Gilmer et al., 2017; Van Steenkiste et al., 2018; Kipf et al., 2018; Battaglia et al., 2018;
Tacchetti et al., 2018).
One can also view our proposed model as a relational graph neural network, where nodes are parameterized as individual RIM and edges are parameterized by the attention mechanism.
Though, it is important to emphasize that semantics of the nodes is learned and that the topology of the graph induced in the proposed model is dynamic, while in most graph neural networks the nodes have a meaning directly tied to the inputs and targets and the topology is ﬁxed and given.
Default Behaviour: Our work is also related to work in behavioural research that deals with two modes of decision making (Dickinson, 1985; Botvinick & Braver, 2015; Kool & Botvinick, 2018): an automatic system that relies on habits and a controlled system that uses some privileged information for decision-making.
The proposed model also has two modes of input processing: activated RIMs rely on external sensory information, and hence seem analogous to the controlled system, while inactive RIMs may more loosely correspond to computation taking place outside of conscious processing and corresponding to the automatic or habit system.
There is RL work aiming to learn default policies , which have shown to improve transfer and generalization in multi-task RL (Teh et al., 2017; Goyal et al., 2019a).
RIMs are different in the sense that we are not trying to learn default policies which affect the environment, instead we want to learn mechanisms, which are more about analyzing or understanding the environment.
State-dependent activation of different primitive policies was also studied by Goyal et al.
(2019b), and
the authors showed that they can learn different primitives, but they also consider that only a single primitive can be active at a particular time-step.
Also, note that primitive policies try to affect the environment, whereas mechanisms try to process or understand the environment.
C M ODEL S ETUP D ETAILS AND H YPERPARAMETERS C. RIM S I MPLEMENTATION
The RIMs model consists of three main components: the input attention, the process for selecting activated RIMs, and the communication between RIMs.
The input attention closely follows the attention mechanism of (Santoro et al., 2018) but with a signiﬁcant modiﬁcation: that all of the weights within the attention mechanism are separate per-block.
Thus we remove the normal linear layers and replace them with a batch matrix multiplication over the RIMs (as each block has its own weight matrix).
Note that the read-key (or query) is a function of the hidden state of each RIM.
For selecting activated RIMs, we compute the top-k attention weight over the RIMs (based on the query).
We then select the activated RIMs, using a mask which zeroes out the outputs from inactive RIMs.
We compute the independent dynamics over all RIMs by using a separate LSTM for each RIM.
Following this, we compute the communication between RIMs as a multihead attention (Santoro et al., 2018), with the earlier-discussed modiﬁcation of having separate weight parameters for each block, and also that we added a skip-connection around the attention mechanism.
This attention mechanism used 4 heads and in general used a key size and value size of 32.
We computed the updates for all RIMs but used the activated-block mask to selectively update only the activated subset of the RIMs.
The use of RIMs introduces two additional hyperparameters over an LSTM/GRU: the number of RIMs and the number of activated RIMs per step.
We also observed that having too few activated RIMs tends to hurt optimization and having too many activated RIMs attenuates the improvements to generalization.
For the future it would be interesting to explore dynamic ways of controlling how many RIMs to activate.
Multiple Heads: Analogously to Vaswani et al.
; Santoro et al.
(2018), we use multiple heads both for communication between RIMs as well as input attention (as in Sec 2.2) by producing different sets of queries, keys, and values to compute a linear transformation for each head (different heads have different parameters), and then applying the attention operator for each head separately in order to select conditioning inputs for the
RIMs.
C. D ETAILED M ODEL H YPERPARAMETERS
Table 3 lists the different hyperparameters.
[Table]
C. O THER A RCHITECTURAL C HANGES THAT WE E XPLORED
We have not conducted systematic optimizations of the proposed architecture.
We believe that even principled hyperparameter tuning may signiﬁcantly improve performance for many of the tasks we have considered in the paper.
We brieﬂy mention a few architectural changes which we have studied:
• On the output side, we concatenate the representations of the different RIMs, and use the concatenated representation for learning a policy (in RL experiments) or for predicting the input at the next time step (for bouncing balls as well as all other experiments).
We empirically found that adding another layer of (multi-headed) key-value attention on the output seems to improve the results.
We have not included this change in the RIMs implementation of this paper.
• In our experiments, we shared the same decoder for all the RIMs, i.e., we concatenate the represen- tations of different RIMS, and feed the concatenated representations to the decoder.
In the future it would be interesting to think of ways to allow a more “structured” decoder.
The reason for this is that even if the RIMs generalize to new environments, the shared decoder can fail to do so.
So changing the structure of decoder could be helpful.
• For the RL experiments, we also tried providing the previous actions, rewards, language instruction as input to decide the activation of RIMs.
This is consistent with the idea of efference copies as proposed by von Helmholtz (1867); von Holst & Mittelstaedt (1950), i.e., using copies of motor signals as inputs.
Preliminary experiments shows that this improves the performance in Atari games.
D E XPERIMENT D ETAILS D. E FFECT OF V ARYING N UMBER AND A CTIVE RIM S ON C OPYING T ASK
We used a learning rate of 0.001 with the Adam Optimizer and trained each model for 150 epochs (unless the model was stuck, we found that this was enough to bring the training error close to zero).
For the RIMs model we used 600 units split across 6 RIMs (100 units per block).
For the LSTM we used a total of 600 units.
We did not explore this extensively but we qualitatively found that the results on copying were not very sensitive to the exact number of units.
The sequences to be copied ﬁrst have 10 random digits (from 0-8), then a span of zeros of some length, followed by a special indicator “9” in the input which instructs the model to begin outputting the copied sequence.
In our experiments, we trained the models with “zero spans” of length 50 and evaluated on the model with “zero spans” of length 200.
We note that all the ablations were run with the default parameters (i.e number of keys, values as for RIMs model) for 100 epochs.
Tab. 4 shows the effect of two baselines as compared to the RIMs model (a) When we allow the input attention for activation of different RIMs but we dont allow different RIMs to communicate.
(b) No Input attention, but we allow different RIMs to communicate with each other.
Tab.
4 shows that the proposed method is better than both of these baselines.
For copy task, we used 1 head in input attention, and 4 heads for RIMs communication.
We note that even with 1 RIM, its not exactly same as a LSTM, because each RIM can still reference itself.
[Table]
D. E FFECT OF V ARYING N UMBER AND A CTIVE RIM S ON A DDING T ASK
In the adding task we consider a stream of numbers as inputs (given as real-values) and then indicate which two numbers should be added together as a set of two input streams which varies randomly between examples.
The length of the input sequence during testing is longer than during training.
This is a simple test of the model’s ability to ignore the numbers which it is not tasked with adding together.
We provide the results in Table 5 which demonstrates that proposed model generalize better for longer testing sequences as well as adding multiple numbers.
We ran the proposed model with different conﬁgurations like changing number of RIMs as well as number of active RIMs.
D. S EQUENTIAL MNIST R ESOLUTION T ASK
In this task we considered classifying binary MNIST digits by feeding the pixels to an RNN (in a ﬁxed order scanning over the image).
As the focus of this work is on generalization, we introduced a variant on this task where the training digits are at a resolution of 14 x 14 (sequence length of 196).
We then evaluated on MNIST digits of different higher resolutions (16 x 16, 19 x 19, and 24 x 24).
When re-scaling the images, we used the nearest-neighbor based down-scaling and performed binarization after re-scaling.
We trained with a learning
[Table]
RIMs ( k
[Table]
=
[Table]
=
[Table] [Table]
rate of 0.0001 and the Adam optimizer.
For RIMs we used a total of 600 hidden units split across 6 RIMs (100 units per RIM).
For the LSTM we used a total of 600 units.
We ran proposed model as well as baselines forepochs.
For sequential MNIST task, we used 1 head in input attention, and 4 heads for RIMs communication.
D. B OUNCING B ALL E NVIRONMENT
We use the bouncing-ball dataset from (Van Steenkiste et al., 2018).
The dataset consists of 50,000 training examples and 10,000 test examples showing ∼ 50 frames of either 4 solid balls bouncing in a conﬁned square geometry, 6-8 balls bouncing in a conﬁned geometry, or 3 balls bouncing in a conﬁned geometry with a random occluded region.
In all cases, the balls bounce off the wall as well as off one another.
We train baselines as well as proposed model for about 100 epochs using 0.0007 as learning rate and using Adam as optimizer (Kingma & Ba, 2014).
We use the same architecture for encoder as well as decoder as in (Van Steenkiste et al., 2018).
We train the proposed model as well as the baselines for 100 epochs.
Our goal in this section is to give more thorough experimental results omitted from the main paper for the sake of brevity.
Below, we highlight a few different results.
D.4. D IFFERENT RIM S ATTEND TO DIFFERENT BALLS
In order to visualize what each RIM is doing, we associate each RIM with a different encoder.
By performing spatial masking on the input, we can control the possible spatial input to each RIM.
We use six non-overlapping horizontal strips and allow only 4 RIMs to be active at a time (shown in Fig. 6).
The mask is ﬁxed mask of zeros with a band of ones that is multiplied by the input to each encoder.
Therefore, each of the 6 encoders gets 1/6th of the input.
The goal was to see how the RIM activation patterns changed/correlated with the locations of the balls.
We ﬁnd that early in training, the RIMs’ activations are strongly correlated with the location of the 4 balls.
However, after training has proceeded for some time this correlation deteriorates.
This is likely because the predictable dynamics of the system do not necessitate constant attention.
D.4. C OMPARISON WITH LSTM B ASELINES
In Figures 7, 8, 9, and 10 we highlight different baselines and how these compare to the proposed RIMs model.
D.4. O CCLUSION
In Fig.
we show the performance of RIMs on the curtain dataset.
We ﬁnd RIMs are able to track balls through the occlusion without difﬁculty.
Note that the LSTM baseline, is also able to track the ball through the “invisible” curtain
D.4. S TUDY OF T RANSFER
It is interesting to ask how models trained on a dataset with 6-8 balls perform on a dataset with 4 balls.
In Fig.
12 we show predictions during feed-in and rollout phases.
D. V IDEO P REDICTION FROM C ROPS
Dataset.
We train all models on a training dataset of 20 K video sequences with 100 frames of 3 balls bouncing in an arena of size 48 × 48 .
We also include an additional ﬁxed ball in the center to make the task more challenging.
We use another 1 K video sequences of the same length and the same number of balls as a held-out validation set.
In addition, we also have 5 out-of-distribution (OOD) test sets with various number of bouncing balls (ranging from 1 to 6 ) and each containing 1 K sequences of length 100 .
Training.
We train all models until the validation loss is saturated, and select the best of three runs.
During training, we automatically decay the learning rate by a factor of 2 if the validation loss does not signiﬁcantly decrease by at least 0 .
01% for ﬁve consecutive epochs.
Evaluation Criteria.
After having trained on the training dataset with 3 bouncing balls, we evaluate the performance on all test datasets with 1 to 6 bouncing balls.
In Figure 13, we report the balanced accuracy (i.e. arithmetic mean of recall and speciﬁcity) and F1-scores (i.e. harmonic mean of precision and recall) to account for class-imbalance
Results.
In Figure 13, out
Baselines: We compared the performance of the proposed method with a baseline LSTM model, as well as state of the art memory model, RMC (Santoro et al., 2018).
As a sanity check we also compare the performance of the proposed method to an oracle baseline that does not model the dynamics (refer to as TTO: Time Travelling Oracle).
D. E NVIRONMENT WITH N OVEL D ISTRACTORS
We evaluate the proposed framework using Adavantage Actor-Critic (A2C) to learn a policy π θ ( a | s, g ) condi- tioned on the goal.
To evaluate the performance of proposed method, we use a range of maze multi-room tasks from the gym-minigrid framework (Chevalier-Boisvert & Willems, 2018) and the A2C implementation from (Chevalier-Boisvert & Willems, 2018).
For the maze tasks, we used agent’s relative distance to the absolute goal position as "goal".
For the maze environments, we use A2C with 48 parallel workers.
Our actor network and critic networks consist of two and three fully connected layers respectively, each of which have 128 hidden units.
The encoder network is also parameterized as a neural network, which consists of 1 fully connected layer.
We use RMSProp with an initial learning rate of 0 . 0007 to train the models.
Due to the partially observable nature of the environment, we further use a LSTM to encode the state and summarize the past observations.
D. M INI G RID E NVIRONMENTS FOR O PEN AI G YM
The MultiRoom environments used for this research are part of MiniGrid, which is an open source gridworld package 2 .
This package includes a family of reinforcement learning environments compatible with the OpenAI
Gym framework.
Many of these environments are parameterizable so that the difﬁculty of tasks can be adjusted (e.g., the size of rooms is often adjustable).
D.7. T HE W ORLD
In MiniGrid, the world is a grid of size NxN. Each tile in the grid contains exactly zero or one object.
The possible object types are wall, door, key, ball, box and goal.
Each object has an associated discrete color, which can be one of red, green, blue, purple, yellow and grey.
By default, walls are always grey and goal squares are always green.
D.7. R EWARD F UNCTION
Rewards are sparse for all MiniGrid environments.
In the MultiRoom environment, episodes are terminated with a positive reward when the agent reaches the green goal square.
Otherwise, episodes are terminated with zero reward when a time step limit is reached.
In the FindObj environment, the agent receives a positive reward if it reaches the object to be found, otherwise zero reward if the time step limit is reached.
The formula for calculating positive sparse rewards is 1 − 0 .
9 ∗ ( step _ count/max _ steps ) .
That is, rewards are always between zero and one, and the quicker the agent can successfully complete an episode, the closer to 1 the reward will be.
The max _ steps parameter is different for each environment, and varies depending on the size of each environment, with larger environments having a higher time step limit.
D.7. A CTION S PACE
There are seven actions in MiniGrid: turn left, turn right, move forward, pick up an object, drop an object, toggle and done.
For the purpose of this paper, the pick up, drop and done actions are irrelevant.
The agent can use the turn left and turn right action to rotate and face one of 4 possible directions (north, south, east, west).
The move forward action makes the agent move from its current tile onto the tile in the direction it is currently facing, provided there is nothing on that tile, or that the tile contains an open door.
The agent can open doors if they are right in front of it by using the toggle action.
D.7. O BSERVATION S PACE
Observations in MiniGrid are partial and egocentric.
By default, the agent sees a square of 7x7 tiles in the direction it is facing.
These include the tile the agent is standing on.
The agent cannot see through walls or closed doors.
The observations are provided as a tensor of shape 7x7x3.
However, note that these are RGB images (which is different from original BabyAI paper).
D.7. L EVEL G ENERATION
The level generation in this task works as follows: (1) Generate the layout of the map (X number of rooms with different sizes (at most size Y) and green goal) (2) Add the agent to the map at a random location in the ﬁrst room.
(3) Add the goal at a random location in the last room.
A neural network parameterized as CNN is used to process the visual observation.
We follow the same architecture as (Chevalier-Boisvert & Willems, 2018) but we replace the LSTM layer with BlockLSTM.
D.7. A DDITIONAL A BLATION
We present one ablation in addition to the ones in Section 4.4.
In this experiment, we study the effect on input attention (i.e top down attention) as well as the use of multi-headed head key-value attention.
We compare the proposed model (with input attention as well as multi-headed key-value attention) with 2 baselines: (a) In which we remove the input attention (and force all the RIMs to communicate with each other (b) We use 1 head for key-value attention as compared to multi-headed key-value attention.
Results comparing the proposed model, with these two baselines is shown in Fig.
In Fig.
16, we show the predictions that result from the model with only one active head.
D. A TARI
We used open-source implementation of PPO from (Kostrikov, 2018) with default parameters.
We ran the proposed algorihtm with 6 RIMs, and kept the number of activated RIMs to 4/5.
We have not done any hyper-parameter search for Atari experiments.
E A DDITIONAL E XPERIMENTS E. I MITATION L EARNING : R OBUSTNESS TO N OISE IN S TATE D ISTRIBUTION
Here, we consider imitation learning where we have training trajectories generated from an expert (Table 6).
We evaluate our model on continuous control tasks in Mujoco (in our case, Half-Cheetah) (Todorov et al., 2012).
We take the rendered images as input and compared the proposed model with recurrent policy (i.e., LSTM).
Since, using rendered image of the input does not tell anything about the velocity of the Half-Cheetah, it makes the task partially observable.
In order to test how well the proposed model generalizes during test, we add some noise (in the joints of the half-cheetah body).
As one can see, after adding noise LSTM baselines performs poorly.
On the other hand, for the proposed model, there’s also a drop in performance but not as bad as for the LSTM baseline.
[Table]
We use the convolutional network from (Ha & Schmidhuber, 2018) as our encoder, a GRU (Chung et al., 2015) with 600 units as deterministic path in the dynamics model, and implement all other functions as two fully connected layers of size 256 with ReLU activations.
Since, here we are using images as input, which makes the task, partially observable.
Hence, we concatenate the past 4 observations, and then feed the concatenated observations input to GRU (or our model).
For our model, we use 6 RIMs, each of size 100, and we set k a = 3 .
We follow the same setting as in (Hafner et al., 2018; Sodhani et al., 2019).
We also compare the proposed method to the baseline where we dont include input attention (or top-down attention).
AS 6 shows, there’s a decline in performance if we dont use input attention, hence justifying the importance
E. T RANSFER ON A TARI
As a very preliminary result, we investigate feature transfer between randomly selected Atari games.
In order to study this question, we follow the experimental protocol of Rusu et al.
We start by training RIMs on three source games (Pong, River Raid, and Seaquest) and test if the learned features transfer to a different subset of randomly selected target games (Alien, Asterix, Boxing, Centipede, Gopher,
Hero, James Bond, Krull, Robotank, Road Runner, Star Gunner, and Wizard of Wor).
We observe, that RIMs result in positive transfer in 9 out of 12 target games, with three cases of negative transfer.
On the other hand progressive networks (Rusu et al., 2016) result in positive transfer in 8 out of 12 target games, and two cases of negative transfer.
We also compare to LSTM baseline, which yields positive transfer in 3 of 12 games.
[Table]
E.2. A TARI R ESULTS : C OMPARISON WITH LSTM-PPO
E.2. A TARI R ESULTS : N O I NPUT ATTENTION
Here we compare the proposed method to the baseline, where we dont use input attention, and we force different RIMs to communicate with each at all the time steps.
[Table]
E.
[Table]
B OUNCING MNIST: D ROPPING INDIVIDUAL RIM S
We use the Stochastic Moving MNIST (SM-MNIST)
(Denton & Fergus, 2018) dataset which consists of sequences of frames of size 64 × 64 , containing one or two MNIST digits moving and bouncing off the walls.
Training sequences are generated on the ﬂy by sampling two different MNIST digits from the training set (60k total digits) and two distinct trajectories.
Here, we show the effect of masking out a particular RIM and study the effect of the masking on the ensemble of RIMs.
Ideally, we would want different RIMs not to co-adapt with each other.
So, masking out a particular
RIM should not really effect the dynamics of the entire model.
We show qualitative comparisons in Fig.
In each of these ﬁgures, the model gets the ground truth image as input for ﬁrst 5 time steps, and then asked to simulate the dynamics for next 25 time-steps.
We ﬁnd that sparsity is needed otherwise different RIMs co-adapt with each other (for ex. see Fig.
We tried similar masking experiments for different models like RMC, Transformers, EntNet (which learns a mixture of experts), LSTMs, but all of them failed to do anything meaningful (after masking).
We suspect this is partly due to learning a homogeneous network.
F N ATURAL L ANGUAGE P ROCESSING : L ANGUAGE M ODELING , M ACHINE T RANSLATION , AND T RANSFER L EARNING
We performed some additional experiments to evaluate how well RIMs improve transfer learning on some widely studied NLP datasets.
We performed an additional experiment where we trained a seq2seq model on the WMT machine translation dataset and evaluated on the IWSLT14 dataset (English to German).
WMT consists of European Parliament text and news articles, whereas IWSLT14 consists of transcribed spoken text (for example, TED talks).
Thus the two datasets are in the same general domain but have fairly distinct content distributions.
Additionally, we considered either training the WMT model on both English to German and English to French (with shared encoders but separate decoders) or only on English to German.
The results are in Table 8.
The LSTM and RIMs models used have a comparable number of parameters in this experiment.
We note that the multi-task training setup substantially hurts the performance of the LSTM baseline, but helps performance when using RIMs (the performance of the transformer is about the same in both settings).
G P SEUDOCODE FOR RIM S A LGORITHM
#Assume these variables are defined: rims_in (number of positions in the incoming input), rims_out (number of RIMs on the current layer), rim_dim ( the number of hidden units in each RIM, for simplicity is the same on the input and output), bsz (the batch size), k (number of RIMs to activate per step) from torch import topk, ones_like, zeros_like, arange, cat def rims_core(inp, h): att_inp, att_scores = input_attention(inp, h) mask = rim_competition(att_scores) h_next = self.block_sparse_gru(att_inp, h) h_next = h_next
_communication h next, mask) h next next + mask
*h return next def input_attention(inp, h): inp = inp.reshape((bsz, rims_in, rim_dim)) att_inp,attn =
self.inp_att(h.reshape((bsz,rims_out,rim_dim)),inp,inp) att_inp = att_inp.reshape((bsz, rim_dim*rims_out)) return att_inp, attn[:,:,0] def rim_competition(att_scores)
k_ind = topk(att_scores,dim=1, sorted =
True,largest=
True,k=rims_out-k)[1] mask = ones_like(att_scores) mask.index put arange .unsqueeze like
[0])) mask =