The Sensory Neuron as a Transformer: Permutation-Invariant Neural Networks for Reinforcement Learning
Year: 2021

Abstract:
In complex systems, we often observe complex global behavior emerge from a collection of agents interacting with each other in their environment, with each individual agent acting only on locally available information, without knowing the full picture. Such systems have inspired development of artificial intelligence algorithms in areas such as swarm optimization and cellular automata. Motivated by the emergence of collective behavior from complex cellular systems, we build systems that feed each sensory input from the environment into distinct, but identical neural networks, each with no fixed relationship with one another. We show that these sensory networks can be trained to integrate information received locally, and through communication via an attention mechanism, can collectively produce a globally coherent policy. Moreover, the system can still perform its task even if the ordering of its inputs is randomly permuted several times during an episode. These permutation invariant systems also display useful robustness and generalization properties that are broadly applicable. Interactive demo and videos of our results: https://attentionneuron.github.io/

heading: 1 Introduction
text: Sensory substitution refers to the brain’s ability to use one sensory modality (e.g., touch) to supply environmental information normally gathered by another sense (e.g., vision). Numerous studies have demonstrated that humans can adapt to changes in sensory inputs, even when they are fed into the wrong channels [5, 6, 25, 64]. But difficult adaptations–such as learning to “see” by interpreting visual information emitted from a grid of electrodes placed on one’s tongue [6], or learning to ride a “backwards” bicycle [64]–require months of training to attain mastery. Can we do better, and create artificial systems that can rapidly adapt to sensory substitutions, without the need to be retrained?
†Equal Contribution
35th Conference on Neural Information Processing Systems (NeurIPS 2021).
Modern deep learning systems are generally unable to adapt to a sudden reordering of sensory inputs, unless the model is retrained, or if the user manually corrects the ordering of the inputs for the model. However, techniques from continual meta-learning, such as adaptive weights [3, 36, 65], Hebbian-learning [52, 53, 57], and model-based [2, 20, 37, 38] approaches can help the model adapt to such changes, and remain a promising active area of research.
In this work, we investigate agents that are explicitly designed to deal with sudden random reordering of their sensory inputs while performing a task. Motivated by recent developments in self-organizing neural networks [27, 55, 61] related to cellular automata [14, 17, 18, 58, 78], in our experiments, we feed each sensory input (which could be an individual state from a continuous control environment, or a patch of pixels from a visual environment) into an individual neural network module that integrates information from only this particular sensory input channel over time. While receiving information locally, each of these individual sensory neural network modules also continually broadcasts an output message. Inspired by the Set Transformer [48, 74] architecture, an attention mechanism combines these messages to form a global latent code which is then converted into the agent’s action space. The attention mechanism can be viewed as a form of adaptive weights of a neural network, and in this context, allows for an arbitrary number of sensory inputs that can be processed in any random order.
In our experiments, we find that each individual sensory neural network module, despite receiving only localized information, can still collectively produce a globally coherent policy, and that such a system can be trained to perform tasks in several popular reinforcement learning (RL) environments. Furthermore, our system can utilize a varying number of sensory input channels in any randomly permuted order, even when the order is shuffled again several times during an episode.
Permutation invariant systems have several advantages over traditional fixed-input systems. We find that encouraging a system to learn a coherent representation of a permutation invariant observation space leads to policies that are more robust and generalizes better to unseen situations. We show that, without additional training, our system continues to function even when we inject additional input channels containing noise or redundant information. In visual environments, we show that our system can be trained to perform a task even if it is given only a small fraction of randomly chosen patches from the screen, and at test time, if given more patches, the system can take advantage of the additional information to perform better. We also demonstrate that our system can generalize to visual environments with novel background images, despite training on a single fixed background. Lastly, to make training more practical, we propose a behavioral cloning scheme to convert policies trained with existing methods into a permutation invariant policy with desirable properties.

heading: 2 Related Work
text: Self-organization is a process where some form of global order emerges from local interactions between parts of an initially disordered system. It is also a property observed in cellular automata (CA) [17, 18, 58], which are mathematical systems consisting of a grid of cells that perform computation by having each cell communicate with its immediate neighbors and performing a local computation to update its internal state. Such local interactions are useful in modeling complex systems [78] and have been applied to model non-linear dynamics in various fields [14]. Cellular Neural Networks [16] were first introduced in the 1980s to use neural networks in place of the algorithmic cells in CA systems. They were applied to perform image processing operations with parallel computation. Eventually, the concept of self-organizing neural networks found its way into deep learning in the form of Graph Neural Networks (GNN) [62, 79].
Using modern deep learning tools, recent work demonstrates that neural CA, or self-organized neural networks performing only local computation, can generate (and re-generate) coherent images [55] and voxel scenes [70, 84], and even perform image classification [61]. Self-organizing neural network agents have been proposed in the RL domain [11, 12, 59, 60], with recent work demonstrating that shared local policies at the actuator level [43], through communicating with their immediate neighbors, can learn a global coherent policy for continuous control locomotion tasks. While existing CA-based approaches present a modular, self-organized solution, they are not inherently permutation invariant. In our work, we build on neural CA, and enable each cell to communicate beyond its immediate neighbors via an attention mechanism that enables permutation invariance.
Meta-learning recurrent neural networks (RNN) [23, 40, 42, 76] have been proposed to approach the problem of learning the learning rules for a neural network using the reward or error signal, enabling meta-learners to learn to solve problems presented outside of their original training domains. The
goals are to enable agents to continually learn from their environments in a single lifetime episode, and to obtain much better data efficiency than conventional learning methods such as stochastic gradient descent (SGD). A meta-learned policy that can adapt the weights of a neural network to its inputs during inference time have been proposed in fast weights [65, 67], associative weights [3], hypernetworks [36], and Hebbian-learning [52, 53] approaches. Recently works [46, 63] combine ideas of self-organization with meta-learning RNNs, and have demonstrated that modular metalearning RNN systems not only can learn to perform SGD-like learning rules, but can also discover more general learning rules that transfer to classification tasks on unseen datasets.
In contrast, the system presented here does not use an error or reward signal to meta-learn or fine-tune its policy. But rather, by using the shared modular building blocks from the meta-learning literature, we focus on learning or converting an existing policy to one that is permutation invariant, and we examine the characteristics such policies exhibit in a zero-shot setting, without additional training.
Attention can be viewed as an adaptive weight mechanism that alters the weight connections of a neural network layer based on what the inputs are. Linear dot-product attention has first been proposed for meta-learning [66], and versions of linear attention with softmax nonlinearity appeared later [33, 51], now made popular with Transformer [74]. The adaptive nature of attention provided the Transformer with a high degree of expressiveness, enabling it to learn inductive biases from large datasets and have been incorporated into state-of-the-art methods in natural language processing [9, 21], image recognition [22] and generation [26], audio and video domains [31, 44, 71].
Attention mechanisms have found many uses for RL [1, 13, 56, 68, 72, 83]. Our work here specifically uses attention to enable communication between arbitrary numbers of modules in an RL agent. While previous work [32, 45, 54, 75, 81, 85] utilized attention as a communication mechanism between independent neural network modules of a GNN, our work focuses on studying the permutation invariant properties of attention-based communication applied to RL agents. Related work [50] used permutation invariant critics to enhance performance of multi-agent RL. Building [34, 82], Set Transformers [48] investigated the use of attention explicitly for permutation invariant problems that deal with set-structured data, which have provided the theoretical foundation for our work.

heading: 3 Method

heading: 3.1 Background
text: Our goal is to devise an agent that is permutation invariant (PI) in the action space to the permutations in the input space. While it is possible to acquire a quasi-PI agent by training with randomly shuffled observations and hope the agent’s policy network has enough capacity to memorize all the patterns, we aim for a design that achieves true PI even if the agent is trained with fix-ordered observations. Mathematically, we are looking for a non-trivial function f(x) : Rn 7→ Rm such that f(x[s]) = f(x) for any x ∈ Rn, and s is any permutation of the indices {1, · · · , n}. A different but closely related concept is permutation equivariance (PE) which can be described by a function h(x) : Rn 7→ Rn such that h(x[s]) = h(x)[s]. Unlike PI, the dimensions of the input and the output must equal in PE.
Self-attentions can be PE. In its simplest form, self-attention is described as y = σ(QK>)V where Q,K ∈ Rn×dq , V ∈ Rn×dv are the Query, Key and Value matrices and σ(·) is a non-linear function. In most scenarios, Q,K, V are functions of the input x ∈ Rn (e.g. linear transformations), and permuting x therefore is equivalent to permuting the rows in Q,K, V and based on its definition it is straightforward to verify the PE property. Set Transformer [48] cleverly replaced Q with a set of learnable seed vectors, so it is no longer a function of input x, thus enabling the output to become PI. A simple, intuitive explanation of the PI property of self-attention is available in Appendix A.1.

heading: 3.2 Sensory Neurons with Attention
text: To create PI agents, we propose to add an extra layer in front of the agent’s policy network π, which accepts the current observation ot and the previous action at−1 as its inputs. We call this new layer AttentionNeuron, and Figure 2 gives an overview of our method. Inside AttentionNeuron, we model the observation ot as an arbitrarily ordered, variable-length list of sensory inputs, each of which is passed into its own sensory neuron, a neural network module. Each sensory neuron only has partial access to the agent’s observation, at time t, the ith neuron can see only the ith component of the observation ot[i]. Combined with the previous action at−1, each sensory neuron computes messages fk(ot[i], at−1) and fv(ot[i]) that are broadcast to the rest of the system. We then use attention to aggregate these messages into a global latent code, mt, that is PI with respect to the inputs.
The operations inside AttentionNeuron can be described by the following two equations. For clarity, Table 1 summarizes the notations as well as the corresponding setups we used for the experiments.
K(ot, at−1) =
[ fk(ot[1], at−1)
· · · fk(ot[N ], at−1)
] ∈ RN×dfk , V (ot) = [ fv(ot[1]) · · ·
fv(ot[N ])
] ∈ RN×dfv (1)
mt = σ ( [QWq][K(ot, at−1)Wk]>√
dq
) [V (ot)Wv] (2)
Equation 1 shows how each of the N sensory neuron independently generates its messages fk and fv, which are functions shared across all sensory neurons. Equation 2 shows the attention mechanism aggregate these messages. Note that although we could have absorbed the projection matrices Wq,Wk,Wv into Q,K, V , we keep them in the equation to show explicitly the formulation. Equation 2 is almost identical to the simple definition of self-attention mentioned earlier. Following [48], we make our Q matrix a bank of fixed embeddings, rather than depend on the observation ot.
Note that permuting the observations only affects the row orders of K and V , and that applying the same permutation to the rows of both K and V still results in the same mt which is PI. As long as we set constant the number of rows in Q, the change in the input size affects only the number of rows in K and V and does not affect the output mt. In other words, our agent can accept inputs of arbitrary length and output a fixed sized mt. Later, we apply this flexibility of input dimensions to RL agents.

heading: 3.3 Design Choices
text: It is worthwhile to have a discussion on the design choices made. Since the ordering of the input is arbitrary, each sensory neuron is required to interpret and identify their received signal. To achieve this, we want fk(ot[i], at−1) to have temporal memories. In practice, we find both RNNs and feed-forward neural networks (FNN) with stacked observations work well, with FNNs being more practical for environments with high dimensional observations.
In addition to the temporal memory, including previous actions is important for the input identification too. Although the former allows the neurons to infer the input signals based on the characteristics of the temporal stream, this may not be sufficient. For example, when controlling a legged robot, most of the sensor readings are joint angles and velocities from the legs, which are not only numerically identically bounded but also change in similar patterns. The inclusion of previous actions gives each sensory neuron a chance to infer the casual relationship between the input channel and the applied actions, which helps with the input identification.
Finally, in Equation 2 we could have combined QWq ∈ RM×dq as a single learnable parameters matrix, but we separate them for two reasons. First, by factoring into two matrices, we can reduce the number of learnable parameters. Second, we find that instead of making Q learnable, using the positional encoding proposed in Transformer [74] encourages the attention mechanism to generate distinct codes. Here we use the row indices in Q as the positions for encoding.

heading: 4 Experiments
text: We experiment on several different RL environments to study various properties of permutation invariant RL agents. Due to the nature of the underlying tasks, we will describe the different architectures of the policy networks used and discuss various different training methods. However, the AttentionNeuron layers in all agents are similar, so we first describe the common setups. Hyperparameters and other details for all experiments are summarized in Appendix A.4.
For non-vision continuous control tasks, the agent receives an observation vector ot ∈ R|O| at time t. We assign N = |O| sensory neurons for the tasks, each of which sees one element from the vector, hence ot[i] ∈ R1, i = 1, · · · , |O|. We use an LSTM [41] as our fk(ot[i], at−1) to generate Keys, the input size of which is 1 + |A| (2 for Cart-Pole and 9 for PyBullet Ant). A simple pass-through function f(x) = x serves as our fv(ot[i]), and σ(·) is tanh. For simplicity, we find Wv = I works well for the tasks, so the learnable components are the LSTM, Wq and Wk.
For vision based tasks, we gray-scale and stack k = 4 consecutive RGB frames from the environment, and thus our agent observes ot ∈ RH×W×k. ot is split into non-overlapping patches of size P = 6 using a sliding window, so each sensory neuron observes ot[i] ∈ R6×6×k. Here, fv(ot[i]) flattens the data and returns it, hence V (ot) returns a tensor of shape N × dfv = N × (6× 6× 4) = N × 144. Due to the high dimensionality for vision tasks, we do not use RNNs for fk, but instead use a simpler method to process each sensory input. fk(ot[i], at−1) takes the difference between consecutive frames (ot[i]), then flattens the result, appends at−1, and returns the concatenated vector. K(ot, at−1) thus gives a tensor of shape N × dfk = N × [(6 × 6 × 3) + |A|] = N × (108 + |A|) (111 for CarRacing and 114 for Atari Pong). We use softmax as the non-linear activation function σ(·), and we apply layer normalization [4] to both the input patches and the output latent code.

heading: 4.1 Cart-pole swing up
text: We examine Cart-pole swing up [29, 30, 35, 86] to first illustrate our method, and also use it to provide a clear analysis of the attention mechanism. We use CartPoleSwingUpHarder [28], a more difficult version of the task where the initial positions and velocities are highly randomized, leading to a higher variance of task scenarios. In the environment, the agent observes [x, ẋ, cos(θ), sin(θ), θ̇], outputs a scalar action, and is rewarded at each step for getting x close to 0 and cos(θ) close to 1.
We use a two-layer neural network as our agent. The first layer is an AttentionNeuron layer with N = 5 sensory neurons and outputs mt ∈ R16. A linear layer takes mt as input and outputs a scalar action. For comparison, we also trained an agent with a two-layer FNN policy with 16 hidden units. We use direct policy search to train agents with CMA-ES [39], an evolution strategies (ES) method.
2Interactive demos and videos of our results available at https://attentionneuron.github.io/
Our agent can perform the task and balance the cart-pole from an initially random state. Its average score is slightly lower than the baseline (See column 1 of Table 2) because each sensory neuron requires some time steps in each episode to interpret the sensory input signal it receives. However, as a trade-off for the performance sacrifice, our agent can retain its performance even when the input sensor array is randomly shuffled, which is not the case for an FNN policy (column 2). Moreover, although our agent is only trained in an environment with five inputs, it can accept an arbitrary number of inputs in any order without re-training3. We test our agent by duplicating the 5 inputs to give the agent 10 observations (column 3). When we replace the 5 extra signals with white noises with σ = 0.1 (column 4), we do not see a significant drop in performance.
The AttentionNeuron layer should possess 2 properties to attain these: its output is permutation invariant to its input, and its output carries task-relevant information. Figure 4 is a visual confirmation of the permutation invariant property, whereby we plot the output messages from the layer and their changes over time from two tests. Using the same random seed, we keep the observation as-is in the first test but we shuffle the order in the second. As the figure shows, the output messages are identical in the two roll-outs. We also perform a simple linear regression analysis on the outputs (based on the shuffled inputs) to recover the 5 inputs in their original order. Table 3 shows the R2 values4 from this analysis, suggesting that some important indicators (e.g. ẋ and θ̇) are well represented in the output.
Table 3: Linear regression analysis on the output. For each of the N = 5 sensory inputs we have one linear regression model with mt ∈ R16 as the explanatory variables.
x ẋ cos(θ) sin(θ) θ̇ R2 0.354 0.620 0.626 0.233 0.550
Table 4: PyBullet Ant results.
Score FNN (teacher) 2700± 28 FNN (shuffled) 232± 112 Ours (ES, shuffled) 2576± 75 Ours (BC, shuffled) 2034± 948 Ours (BC, shuffled, larger) 2579± 457

heading: 4.2 PyBullet Ant
text: While direct policy search methods such as evolution strategies (ES) can train permutation invariant RL agents, oftentimes we already have access to pre-trained agents or recorded human data performing the task at hand. Behavior cloning (BC) can allow us to convert an existing policy to a version that is permutation invariant with desirable properties associated with it.
In Table 4, we train a standard two-layer FNN policy to perform AntBulletEnv-v0, a 3D locomotion task in PyBullet [19], and use it as a teacher for BC. For comparison, we also train a two-layer agent with AttentionNeuron for its first layer. Both networks are trained with ES. Similar to CartPole, we expect to see a small performance drop due to some time steps required for the agent to interpret an arbitrarily ordered observation space. We then collect data from the FNN teacher policy to train permutation invariant agents using BC. More details of the BC setup can be found in Appendix A.4.2.
3Because our agent was not trained with normalization layers, we scaled the output from the AttentionNeuron layer by 0.5 to account for the extra inputs in the last 2 experiments.
4R2 measures the goodness-of-fit of a model. An R2 of 1 implies that the regression perfectly fits the data.
The performance of the BC agent is lower than the one trained from scratch with ES, despite having the identical architecture. This suggests that the inductive bias that comes with permutation invariance may not match the original teacher network, so the small model used here may not be expressive enough to clone any teacher policy, resulting in a larger variance in performance. A benefit of gradient-based BC, compared to RL, is that we can easily train larger networks to fit the behavioral data. We show that increasing the size of the subsequent layers for BC does enhance the performance.
As we will demonstrate next, BC is a useful technique for training permutation invariant agents in environments with high dimensional visual observations that may require larger networks.

heading: 4.3 Atari Pong
text: Here, we are interested in solving screen-shuffled versions of vision-based RL environments, where each observation frame is divided up into a grid of patches, and like a puzzle, the agent must process the patches in a shuffled order to determine a course of action to take. A shuffled version of Atari Pong [8] (See Figure 1, right pair) can be especially hard for humans to play when inductive biases from human priors [24] that expect a certain type of spatial structure is missing from the observations.
But rather than throwing away the spatial structure entirely from our solution, we find that convolution neural network (CNN) policies work better than fully connected multi-layer perceptron (MLP) policies when trained with behavior cloning for Atari Pong. In this experiment, we reshape the output mt of the AttentionNeuron layer fromR400×32 toR20×20×32, a 2D grid of latent codes, and pass this 2D grid into a CNN policy. This way, the role of the AttentionNeuron layer is to take a list of unordered observation patches, and learn to construct a 2D grid representation of the inputs to be used by a downstream policy that expects some form of spatial structure in the codes. Our permutation invariant policy trained with BC can consistently reach a perfect score of 21, even with shuffled screens. The details of the CNN policy and BC training can be found in Appendix A.4.3.
Unlike typical CNN policies, our agent can accept a subset of the screen, since the agent’s input is a variable-length list of patches. It would thus be interesting to deliberately randomly discard a certain percentage of the patches and see how the agent reacts. The net effect of this experiment for humans is similar to being asked to play a partially occluded and shuffled version of Atari Pong (see Figure 5, right). During training via BC, we randomly remove a percentage of observation patches. In tests, we fix the randomly selected positions of patches to discard during an entire episode.
We present the results in a heat map in Figure 5 (left), where the y-axis shows the patches removed during training and the x-axis gives the patch occlusion ratio in tests. The diagram shows clear patterns for interpretation. Looking horizontally along each row, the performance drops because the agent sees less of the screen which increases the difficulty. Interestingly, an agent trained at a high occlusion rate of 80% rarely wins against the Atari opponent, but once it is presented with the full set of patches during tests, it is able to achieve a fair result by making use of the additional information.
To gain insights into understanding the policy, we projected the AttentionNeuron layer’s output in a test roll-out to 2D space using t-SNE [73]. In Figure 6, we highlight several groups and show their
corresponding inputs. The AttentionNeuron layer clearly learned to cluster inputs that share similar features. For example, the 3 sampled inputs in the blue group show the situation when the agent’s paddle moved toward the bottom of the screen and stayed there. Similarly, the orange group shows the cases when the ball was not in sight, this happened right before/after a game started/ended. We believe these discriminative outputs enabled the downstream policy to accomplish the agent’s task.

heading: 4.4 CarRacing
text: We find that encouraging an agent to learn a coherent representation of a deliberately shuffled visual scene leads to agents with useful generalization properties. Such agents are still able to perform their task even if the visual background of the environment changes, despite being trained only on a single static background. Out-of-domain generalization is an active area, and here, we combine our method with AttentionAgent [72], a method that uses selective, hard-attention via a patch voting mechanism. AttentionAgents in [72] generalize well to several unseen visual environments where task irrelevant elements are modified, but fail to generalize to drastic background changes in a zero-shot setting.
In this experiment, we combine the permutation invariant AttentionNeuron layer with the policy network used in AttentionAgent. As their hard-attention-based policy is non-differentiable, we train the entire system using ES. We reshape the AttentionNeuron layer’s outputs to adapt for the policy network. Specifically, we reshape the output message to mt ∈ R32×32×16 such that it can be viewed as a 32-by-32 grid of 16 channels. The end result is a policy with two layers of attention: the first layer outputs a latent code book to represent a shuffled scene, and the second layer performs hard attention to select the top K = 10 codes from a 2D global latent code book. A detailed description of the selective hard attention policy from [72] and other training details can be found in Appendix A.4.4.
We first train the agent in the CarRacing [47] environment, and report the average score from 100 test roll-outs in Table 5. As the first column shows, our agent’s performance in the training environment is slightly lower but comparable to the baseline method, as expected. But because our agent accepts randomly shuffled inputs, it is still able to navigate even when the patches are shuffled. Figure 1 (left pair) gives an illustration, where the right screen is what our agent observes and the left is for human visualization. A human will find driving with the shuffled observation to be very difficult because we are not constantly exposed to such tasks, just like in the “reverse bicycle” example mentioned earlier.
Without additional training or fine-tuning, we test whether the agent can also navigate in four modified environments where the green grass background is replaced with various images (See Figure 7). As Table 5 (from column 2) shows, our agent generalizes well to most of the test environments with only mild performance drops while the baseline method fails to generalize. We suspect this is because
Table 5: CarRacing Test Results.
Training Env KOF Mt. Fuji Ukiyoe DS
AttentionAgent [72] 901± 54 −81± 4 −57± 38 −107± 50 −56± 23 NetRand [49] 480± 144 20± 84 356± 159 533± 111 −27± 34 NetRand + AttentionAgent 885± 64 −51± 14 709± 94 656± 131 122± 134 Ours 801± 147 646± 189 503± 152 661± 140 171± 146
Figure 7: Screenshots of test environments. In each pair of images, the left is for human visualization and the right is what our agent sees. From the top left and in the clockwise order, the environments are “KOF”, “Mt. Fuji”, “DS” and “Ukiyoe”.
the AttentionNeuron layer has transformed the original RGB space to a useful hidden representation (represented by mt) that has eliminated task irrelevant information after observing and reasoning about the sequences of (ot, at−1) during training, enabling the downstream hard attention policy to work with an optimized abstract representation tailored for the policy, instead of raw RGB patches.
We also compare our method to NetRand [49], a simple but effective technique developed to perform similar generalization tasks. In the second row of Table 5 are the results of training NetRand on the base CarRacing task. The CarRacing task proved to be too difficult for NetRand, but despite a low performance score of 480 in the training environment, the agent generalizes well to the “Mt. Fuji” and “Ukiyoe” modifications. In order to obtain a meaningful comparison, we combine NetRand with AttentionAgent so that it can get close to a mean score of 900 on the base task. To do that, we use NetRand as an input layer to the AttentionAgent policy network, and train the combination end-to-end using ES, which is consistent with our proposed method for this task. The combination attains a respectable mean score of 885, and as we can see in the third row of the above table, this approach also generalizes to a few of the unseen modifications of the CarRacing environment.
Our score on the base CarRacing task is lower than NetRand, but this is expected since our agent requires some amount of time steps to identify each of the inputs (which could be shuffled), while the NetRand and AttentionAgent agent will simply fail on the shuffled versions of CarRacing. Despite this, our method still compares favorably on the generalization performance.
We visualize the attentions from the AttentionNeuron layer in Figure 8. In CarRacing, the agent has learned to focus its attention (indicated by the highlighted patches) on the road boundaries which are intuitive to human beings and are critical to the task. Notice that the attended positions are consistent before and after the shuffling. More details about this visualization can be found in Appendix A.4.4.

heading: 5 Discussion and Future Work
text: In this work, we investigate the properties of RL agents that can treat their observations as an arbitrarily ordered, variable-length list of sensory inputs. By processing each input stream independently, and consolidating the processed information using attention, our agents can still perform their tasks even if the ordering of the observations is randomly permuted several times during an episode, without explicitly training for frequent re-shuffling (See Table 6).
Applications By presenting the agent with shuffled, and even incomplete observations, we encourage it to interpret the meaning of each local sensory input and how they relate to the global context. This could be useful in many real world applications. For example, such policies could avoid errors due to cross-wiring or complex, dynamic input-output mappings when being deployed in real robots. A similar setup to the CartPole experiment with extra noisy channels could enable a system that receives thousands of noisy input channels to identify the small subset of channels with relevant information.
Limitations For visual environments, patch size selection will affect both performance and computing complexity. We find that patches of 6x6 pixels work well for our tasks, as did 4x4 pixels to some extent, but single pixel observations fail to work. Small patch sizes also result in a large attention matrix which may be too costly to compute, unless approximations are used [15, 77, 80].
Another limitation is that the permutation invariant property applies only to the inputs, and not to the outputs. While the ordering of the observations can be shuffled, the ordering of the actions cannot. For permutation invariant outputs to work, each action will require feedback from the environment, including reward information, in order to learn the relationship between itself and the environment.
Societal Impact Like most algorithms proposed in computer science and machine learning, our method can be applied in ways that will have potentially positive or negative impacts to society. While our small-scale, self-contained experiments study only the properties of agents that are PI to their observations, and we believe our results do not directly cause harm to society, the robustness and flexible properties of the method may be of use for data-collection systems that receive data from a large variable number of sensors. For instance, one could apply permutation invariant sensory systems to process data from millions of sensors for anomaly detection, which may lead to both positive or negative impacts, if used in applications such as large-scale sensor analysis for weather forecasting, or deployed in large-scale surveillance systems that could undermine our basic freedoms.
Our work also provides a way to view the Transformer [74] through the lens of self-organizing neural networks. Transformers are known to have potentially negative societal impacts highlighted in studies about possible data-leakage and privacy vulnerabilities [10], malicious misuse and issues concerning bias and fairness [7], and energy requirements for training them [69].
Future Work An interesting future direction is to also make the action layer have the same properties, and model each “motor neuron” as a module connected using attention. With such methods, it may be possible to train an agent with an arbitrary number of legs, or control robots with different morphology using a single policy that is also provided with a reward signal as feedback. We look forward to seeing future works that include signals such as environmental rewards to train PI meta-learning agents that can adapt to not only changes in the observed environment, but also to changes to itself.

heading: Acknowledgements
text: The authors would like to thank Rishabh Agarwal, Jie Tan, Yingtao Tian, Douglas Eck, Aleksandra Faust and our NeurIPS2021 reviewers for valuable discussion and feedback. The experiments in this work were conducted using virtual machines provided by Google Cloud Platform.

Review summaries:
This work investigates the problem of shuffled or dropped out sensory inputs for reinforcement learning agents. The authors propose AttentionNeuron, a permutation-invariant attention layer operating on neurons which independently process the input currently present at its location. Each neuron utilizes its past context and the past action to interpret the seen input, and the attention mechanism combines the outputs of each neuron to generate a globally-aware embedding to be used for a standard policy architecture. The authors show that (1) AttentionNeuron is robust to shuffled and noisy observations on CartPole, (2) performing behavior cloning with an AttentionNeuron architecture can yield a policy robust to shuffling on Ant, (3) AttentionNeuron is robust to patch-level shuffling and dropouts on Pong, (4) AttentionNeuron improves robustness to drastic background changes on CarRacing, and (5) AttentionNeuron is robust to shuffling within a single episode.

This paper presents a sensory neuron architecture as a layer in a neural network trained for reinforcement learning and claims that this sensory neuron makes a network generally permutation-invariant. There is an extensive related-work section covering examples of sensory modality adaptation in neuroscience, cellular automata, meta-learning, and attention, setting up the presented approach which uses collective intelligence of only distributed modules with only local awareness, self-organization through attention, and adaptation of an existing policy to be permutation invariant. The paper then presents a mathematical formulation for the AttentionNeuron architecture, including its temporal memory, to be used as the first layer in an RL agent. The paper next tests its approach on four different tasks, some with multiple environments and concludes with some discussion of the results which appear to be robust to permutation of the input vector unlike the baseline feedforward network.