extfieldsofstudy:
Computer Science
Medicine

text:
Catastrophic Interference in Reinforcement Learning: A Solution Based on Context Division and Knowledge Distillation

The powerful learning ability of deep neural networks enables reinforcement learning agents to learn competent control policies directly from continuous environments. In theory, to achieve stable performance, neural networks assume i.i.d. inputs, which unfortunately does no hold in the general reinforcement learning paradigm where the training data is temporally correlated and non-stationary. This issue may lead to the phenomenon of"catastrophic interference"and the collapse in performance. In this paper, we present IQ, i.e., interference-aware deep Q-learning, to mitigate catastrophic interference in single-task deep reinforcement learning. Specifically, we resort to online clustering to achieve on-the-fly context division, together with a multi-head network and a knowledge distillation regularization term for preserving the policy of learned contexts. Built upon deep Q networks, IQ consistently boosts the stability and performance when compared to existing methods, verified with extensive experiments on classic control and Atari tasks. The code is publicly available at: https://github.com/Sweety-dm/Interference-aware-Deep-Q-learning.

I. INTRODUCTION
I N recent years, the successful application of deep neural networks (DNNs) in reinforcement learning (RL) [2] has provided a new perspective to boost its performance on highdimensional continuous problems. With the powerful function approximation and representation learning capabilities of DNNs, deep RL is regarded as a milestone towards constructing autonomous systems with a higher level of understanding of the physical world [3]. Currently, deep RL has demonstrated great potential on complex tasks, from learning to play video games directly from pixels [4], [5] to making immediate decisions on robot behavior from camera inputs [6]- [8]. However, these successes are limited and prone to catastrophic interference 1 due to the inherent issue of DNNs Tiantian Zhang, and Bo Yuan are with the Intelligent Computing Lab, Shenzhen International Graduate School, Tsinghua University, 518055 Shenzhen, P.R. China (e-mail: ztt19@mails.tsinghua.edu.cn; boyuan@ieee.org).
Bin Liang is with the Research Center for Navigation and Control, Department of Automation, Tsinghua University, 100084 Beijing, P.R. China (e-mail: liangbin@mail.tsinghua.edu.cn). * Corresponding Author. 1 A phenomenon observed in neural networks where later training is likely to overwrite and interfere with previously learned good policies and significantly degrades the performance on previous tasks. The agent experiences the following data distribution transitions during learning:P 1 − → P 2 − → P 3 − → P 1 − → P 3. (b) The stability-plasticity trade-off in DNNs [1]. Sharing: both learning phases train the same model; Transfer: the current learning phase continues training on the model derived from the old learning phase; Interference: after the model is trained on P 2, the weights in green are changed in the right network, affecting the model performance on P 1. (c) The learning curves where the solid line corresponds to the data distribution transitions in (a) and the dashed line shows the training performance. Before T 3, the data distribution is gradually drifted from P 1 to P 2 and to P 3. When the model fits to P 3, the learned policies on P 1 and P 2 are interfered, resulting in catastrophically degraded performance when the agent encounters states from P 1 again. Therefore, the model needs to be retrained on P 1 (in the time period T 3 → T 4). The same problem occurs in the time period T 4 → T 5.
in face of the non-stationary data distributions, and they rely heavily on a combination of various subtle strategies, such as experience replay [4] and fixed target networks [5], or distributed training architecture [9]- [11].
LG] 1 Sep 2022 the agent continually faces new tasks and the neural network may quickly fit to the data distribution of the current task, while potentially overwriting the information related to learned tasks, leading to catastrophic forgetting of the solutions of old tasks. The underlying reason behind this phenomenon is the global generalization and overlapping representation of neural networks [21], [22]. Neural networks training normally assumes that the inputs are identically and independently distributed (i.i.d.) from a fixed data distribution and the output targets are sampled from a fixed conditional distribution. Only when this assumption is satisfied, can positive generalization be ensured among different batches of stochastic gradient descent. However, when the data distribution is drifted during training, the information learned from old tasks may be negatively interfered or even overwritten by the newly updated weights, resulting in catastrophic interference.
Deep RL is essentially a CL problem due to its learning mode of exploring while learning [20], and it is particularly vulnerable to catastrophic interference, even within many single-task settings where the environment is stationary (such as Atari 2600 games, or even simpler classic control tasks in OpenAI Gym) [23]- [26]. The non-stationarity of data distributions in the single-task RL is mainly attributed to the following properties of RL. Firstly, the inputs of RL are sequential observations received from the environment, which are temporally correlated. Secondly, in the progress of learning, the agent's decision making policy changes gradually, which makes the observations non-stationary. Thirdly, RL methods rely heavily on bootstrapping, where the RL agent uses its own estimated value function as the target, making the target outputs also non-stationary. In addition, as noted in [24], replay buffers with prioritized experience replay [27] that preferentially sample experiences with higher temporaldifference (TD) errors will also exasperate the non-stationarity of training data. Once the distribution of training data encounters notable drift, catastrophic interference and a chain reaction are likely to occur, resulting in a sudden deterioration of the training performance, as shown in Fig. 1.
Currently, there are two major strategies for dealing with catastrophic interference in the single-task RL training: experience replay [4], [5] and local optimization [25], [26]. The former usually exhibits high-level sensitivity to key parameters (e.g., replay buffer capacity) and often requires maintaining a large experience storage memory. Furthermore, the sufficiently large memory may increase the degree of off-policyness of transitions in the buffer [28], violating the requirement of current state-of-the-art algorithms that the data should be close to the on-policy distribution, even for off-policy algorithms like DQN. The latter advocates local network updating for the data with a specific distribution instead of global generalization to reduce the representation overlap among different data distributions. The major issues are that some methods are limited in the capability of model transfer among differently distributed data [25], [26], or require pretraining and may not be suitable for the online settings [26].
In this paper, we focus on the catastrophic interference problem caused by state distribution drift in the single-task RL. We propose a interference-aware scheme with low buffer-size sensitivity called Interference-aware Deep Q-learning (IQ 2 ) that estimates the value function online for each state distribution by minimizing the weighted sum of the original loss function of RL algorithms and the regularization term regarding the interference among different groups of states. The schematic architecture is shown in Fig. 3.
In order to mitigate the interference among different state distributions during model training, we introduce the concept of "context" into the single-task RL, and propose a context division strategy based on online clustering. We show that it is essential to decouple the correlations among different state distributions with this strategy to divide the state space into a series of independent contexts (each context is a set of states distributed close to each other, conceptually similar to "task" in the multi-task CRL). To achieve efficient and adaptive partition, we employ Sequential K-Means Clustering [29] to process the states encountered during training in real time. Then, we parameterize the value function by a neural network with multiple output heads commonly used in multitask learning [19], [30], [31] in which each output head specializes on a specific context, and the feature extractor is shared across all contexts. In addition, we apply knowledge distillation as a regularization term in the objective function for value function estimation, which can preserve the learned policies while the RL agent is trained on states guided by the current policy, to further avoid the interference caused by the shared low-level representation. Furthermore, to ease the curse of dimensionality in high-dimensional state spaces, we employ a random encoder as its low-dimensional representation space can effectively capture the information about the similarity among states without any representation learning [32]. Clustering is then performed in the low-dimensional representation space of the randomly initialized convolutional encoder.
The contributions of this paper are summarized as follows: 1) A novel context division strategy is proposed for the single-task RL. It is essential as the widely studied multitask CRL methods cannot be used directly to reduce interference in the single-task RL due to the lack of predefined task boundaries. This strategy can detect contexts adaptively online, so that each context can be regarded as a task in multi-task settings. In this way, the strategies designed for the multi-task CRL can be used in the singletask RL to mitigate catastrophic interference. 2) A novel RL training scheme called IQ based on multihead neural networks is proposed following the context division strategy. By incorporating the knowledge distillation loss into the objective function, IQ can better alleviate the interference suffered in the single-task RL than existing methods in a fully online manner. 3) A fixed random encoder is introduced into the context division of high-dimensional state spaces, which further stabilizes the performance of IQ on complex RL tasks (e.g., image-level inputs) compared with the underlying RL trained encoder.

4)
Extensive experiments on a suite of OpenAI Gym standard benchmark environments ranging from classic control tasks to high-dimensional complex Arcade Learning Environments (ALE) [33] under various replay buffer capacity settings are conducted to validate that the overall superiority of our method over baselines in terms of the stability and the maximum achieved cumulative reward. The rest of this paper is organized as follows. Section II reviews the relevant strategies for alleviating catastrophic interference as well as context detection and identification. Section III introduces the nature of RL in terms of continual learning and gives an example analysis of catastrophic interference in the single-task RL. The details of IQ are shown in Section IV, and experimental results and analyses are presented in Section V. Finally, this paper is concluded in Section VI with some discussions and directions for future work.

II. RELATED WORK
Catastrophic interference within the single-task RL is a special case of CRL, which involves not only the strategies to mitigate interference but also the context detection and identification techniques.

A. Multi-task Continual Reinforcement Learning
Multi-task CRL has been an active research area with the development of RL architectures [34]. Existing methods mainly consist of three categories: experience replay-based, regularization-based, and parameter isolation-based methods.
The core idea of experience replay is to store samples of previous tasks in raw format (e.g., Selective Experience Replay (SER) [35], Meta Experience Replay (MER) [1], Continual Learning with Experience And Replay (CLEAR) [36]) or generate pseudo-samples from a generative model (e.g., Reinforcement Pseudo Rehearsal (RePR) [37]) to maintain the knowledge about the past in the model. These previous task samples are replayed while learning a new task to alleviate interference, in the form of either being reused as model inputs for rehearsal [35], [37] or constraining the optimization of the new task loss [1], [36]. Experience replay has become a very successful approach to tackling interference in CRL. However, the raw format may result in significant storage requirements for complex CRL settings. Although the generative model can be exempted from a replay buffer, it is still difficult to capture the overall distribution of previous tasks.
Regularization-based methods avoid storing raw inputs by introducing an extra regularization term into the loss function to consolidate previous knowledge while learning on new tasks. The regularization term includes penalty computing and knowledge distillation. The former focuses on reducing the chance of weights being modified. For example, Elastic Weight Consolidation (EWC) [13] and UNcertainty guided Continual LEARning (UNCLEAR) [19] use Fisher matrix to measure the importance of weights and protect important weights on new tasks. The latter is a form of knowledge transfer [38], which expects that the model trained on a new task can still perform well on the old ones. It is often used for policy transfer from one model to another (e.g., Policy Distillation [39], Genetic Policy Optimization (GPO) [40], Distillation for Continual Reinforcement learning (DisCoRL) [41]). This family of solutions is easy to implement and tends to perform well on a small number of tasks, but still faces challenges as the number of tasks increases.
Parameter isolation-based methods dedicate different model parameters to each task, to prevent any possible interference among tasks. Without the constraints on the size of neural networks, one can grow new branches for new tasks, while freezing previous task parameters (e.g., Progressive Natural Networks (PNN) [42]). Alternatively, the architecture remains static, with fixed parts being allocated to each task. For instance, PathNet [14] uses a genetic algorithm to find a path from input to output for each task in the neural network and isolates the used network parts in parameter level from the new task training. These methods typically require networks with enormous capacity, especially when the number of tasks is large, and there is often unnecessary redundancy in the network structure, bringing a great challenge to model storage and efficiency.

B. Single-task Reinforcement Learning
Compared with the multi-task CRL, catastrophic interference in the single-task RL remains an emerging research area, which has been relatively under-explored. There are two primary aspects of previous studies: one is finding supporting evidence to confirm that catastrophic interference is indeed prevalent within a specific RL task, and the other is proposing effective strategies for dealing with it.
Researchers in DeepMind studied the learning dynamics of the single-task RL and developed a hypothesis that the characteristic coupling between learning and data generation is the main cause of interference and performance plateaus in deep RL systems [23]. Recent studies further confirmed this hypothesis and its universality in the single-task RL through large-scale empirical studies (called Memento experiments) in Atari 2600 games [24]. However, none of these studies has suggested any practical solution for tackling the interference.
In order to mitigate interference, many deep RL algorithms such as DQN [5] and its variants (e.g., Double DQN [43], Rainbow [44]) employ experience replay and fixed target networks to produce approximately i.i.d. training data, which may quickly become intractable in terms of memory requirement as task complexity increases. Furthermore, even with sufficient memory, it is still possible to suffer from catastrophic interference due to the imbalanced distribution of experiences.
In recent studies [21], [25], [26], researchers proposed some methods based on local representation and optimization of neural networks, which showed that interference can be reduced by promoting the local updating of weights while avoiding global generalization. Sparse Representation Neural Network (SRNN) [26] induces sparse representations in neural networks by introducing a distributional regularizer, which requires a large batch of data generated by a fixed policy that covers the space for pretraining and have not been extended to the online setting. Dynamic Self-Organizing Map (DSOM) [25] with neural networks introduces a DSOM module to induce such locality updates. These methods can reduce interference to some extent, but they may inevitably suffer from the lack of positive transfer in the representation layer and require larger network capacity, which is not desirable in complex tasks. Recently, discretizing (D-NN) and tile coding (TC-NN) were used to remap the input observations to a high-dimensional space to sparsify input features, reducing the activation overlap [21]. However, tile coding increases the dimension of inputs to a neural network, which can lead to scalability issues for spaces with high dimensionality.

C. Context Detection and Identification
Context detection and identification is a fundamental step for learning task relatedness in CL. Most multi-task CL methods aforementioned rely on well-defined task boundaries, and are usually trained on a sequence of tasks with known labels or boundaries. Existing context detection approaches commonly leverage statistics or Bayesian inference to identify task boundaries.
On the one hand, some methods tend to be reactive to a changing distribution by finding change points in the pattern of state-reward tuples (e.g., Context QL [45]), or tracking the difference between the short-term and long-term moving average rewards (e.g., CRL-Unsup [46]), or splitting a game into contexts using the undiscounted accumulated game score as a task contextualization [47]. These methods can be agile in responding to scenarios with abrupt changes among contexts or tasks, but are insensitive to smooth transitions from one context to another.
On the other hand, some more ambitious approaches try to learn a belief of the unobserved context state directly from the history of environment interactions, such as Forget-me-not Process (FMN) [48] for piecewise-repeating data generating sources, and Continual Unsupervised Representation Learning (CURL) [49] for task inference without any knowledge about task identity. However, they both need to be pretrained with the complete data before applied to CL problems, and CURL itself also needs additional techniques to deal with the interference.
Furthermore, Ghosh et al. [50] proposed to partition the initial state space into a finite set of contexts by performing a K-Means clustering procedure, which can decompose more complex tasks, but cannot completely decouple the correlations among different state distributions from the perspective of interference prevention.

III. PRELIMINARIES AND PROBLEM STATEMENT
To better characterize the problem studied in this paper, some key definitions and glossaries of CRL problems are introduced in this section.

A. Definitions and Glossaries
Some important definitions of RL relevant to this paper are presented as follows.
Definition 1 (RL Paradigm [2]). A RL problem is regarded as a Markov Decision Process (MDP), which is defined as a tuple M = S, A, P, R, γ , where S is the set of states; A is the set of actions; P : S × A × S → [0, 1] is the environment transition probability function; R : S × A × S → R is the reward function, and γ ∈ [0, 1] is the discount factor.
According to Definition 1, at each time step t ∈ N, the agent moves from S t to S t+1 with probability P (S t+1 |S t , A t ) after taking action A t , and receives reward R(S t , A t ). Based on this definition, the optimization objective of value-based RL models is defined as follow: Definition 2 (RL Optimization Objective [20]). The optimization objective of the value-based RL is to learn a policy π(a|s) with internal parameter θ ∈ Θ that maximizes the expected long-term discounted returns for each (s, a) in time, also known as the value function: Here, the expectation is over the process that generates a history using P and decides actions from π until the end of the agent's lifetime.
The optimization objective in Definition 2 does not just concern itself with the current state, but also the full expected future distribution of states. As such, it is possible to overcome the catastrophic interference for RL over non-stationary data distributions. However, much of the recent work in RL has been in the so called episodic environments, which optimizes the episodic RL objective: Definition 3 (Episodic RL Optimization Objective [20]). Given some future horizon H, find a policy π(a|s), optimizing the expected discounted returns: Here, to ensure the feasibility and ease of implementation of optimization, the objective is only optimized over a future horizon H until the current episode terminates.
It is clear that the episodic objective in Definition 3 is biased towards the current episode distribution while ignoring the possibly far more important future episode distributions over the agent's lifetime. Plugging in such an objective directly into the non-stationary RL settings leads to biased optimization, which is likely to cause catastrophic interference effects.
For large scale domains, the value function is often approximated with a member of the parametric function class, such as a neural network with parameter θ ∈ Θ, expressed as Q(s, a; θ), which is fit online using experience samples of the form (s, a, r, s ). This experience is typically collected into a buffer B from which batches are later drawn at random to form a stochastic estimate of the loss: where L : R → R is the agent's loss function, and µ ∈ P(B) is the distribution that defines its sampling strategy. In general, the parameter θ − used to compute the target Q(s , a ; θ − ) is a prior copy of that used for action selection (as the settings of DQN [5]).
Additionally, it is necessary to clarify some important glossaries in relation to CL.
1) Non-stationary [51]: a process whose state or probability distribution changes with time.
2) Interference [22]: a type of influence between two gradient-based processes with objectives J 1 , J 2 , sharing parameter θ. Interference is often characterized in the first order by the inner product of their gradients: and can be seen as being constructive (ρ > 0, transfer) or destructive (ρ < 0, interference), when applying a gradient update using θ J 1 on the value of J 2 .
3) Catastrophic Interference [12], [51]: a phenomenon observed in neural networks training where learning a new task significantly degrades the performance on previous tasks.

B. Problem Statement
The interference within the single-task RL can be approximately measured by the difference in TD errors before and after model update under the current policy, referred to as Approximate Expected Interference (AEI) [52]: whered is the distribution of (s, a, r, s ) under the current policy and δ(s, a, r, s ; θ) = r + γ max a ∈A Q(s , a ; θ) − Q(s, a; θ) is the TD error.
To illustrate the interaction between interference and the agent's performance during the single-task RL training, we run an experiment on CartPole using the DQN implemented in OpenAI Baselines 3 , and set the replay buffer size N to 100, a small capacity to trigger interference to highlight its effect. We trained the agent for 300K environment steps and approximatedd with a buffer containing recent transitions of capacity 10K to evaluate the AEI value according to Eq. (5) after each update. Fig. 2 shows two segments of the interference and performance curves during training from which we can see that the performance started to oscillate when AEI started to increase (e.g., t ≈ 118K, t ≈ 143K, and t ≈ 175K in Fig. 2(a), and t ≈ 230K in Fig. 2(b)). In general, the performance of the agent tends to drop significantly in the presence of increasing interference. This result provides direct evidence that interference is correlated closely with the stability of the single-task RL model.
From the analysis above, we state the problem investigated in this paper as: proposing a novel and effective training scheme for the single-task RL, to reduce catastrophic interference and performance oscillation during training, improving the stability and overall performance simultaneously.

IV. THE PROPOSED METHOD
In this section, we give a detailed description of our IQ scheme whose architecture is shown in Fig. 3. IQ consists of 3 OpenAI Baselines is a set of high-quality implementations of RL algorithms implemented by OpenAI: https://github.com/openai/baselines.
three main components, which are jointly optimized to mitigate catastrophic interference in the single-task RL: context division, knowledge distillation, and the collaborative training of the multi-head neural network. On the basis of IQ, we further propose IQ-RE with a random encoder for the efficient contextualization of high-dimensional state spaces. As mentioned before, catastrophic interference is an undesirable byproduct of global updates to the neural network weights on data whose distribution changes over time. A rational solution to this issue is to estimate an individual value function for each distribution, instead of using a single value function for all distributions. When an agent updates its value estimation of a state, the update should only affect the states within the same distribution. With this intuition in mind, we adopt a multi-head neural network with shared representation layers to parameterize the distribution specific value functions.
The IQ scheme proposed in this paper can be incorporated into any existing value-based RL methods to train a piecewise Q-function for the single-task RL. The neural network is parameterized by a shared feature extractor and a set of linear output heads, corresponding to each context. As shown in Fig. 3, the set of weights of the Q-function is denoted by θ = {θ S , θ T , θ F }, where θ S is a set of shared parameters while θ T and θ F are both context specific parameters: θ T is for the context that corresponds to the current input state s, and θ F is for others. In this section, we take the combination of IQ and the basic RL algorithm DQN as an illustrative example.

A. Context Division
In MDPs, states (or "observations") represent the most comprehensive information regarding the environment.

Knowledge Distillation & Joint Optimization
3. An overview of the IQ scheme. This framework consists of three components: 1) Context division, including state assignment and centroid update. Adaptive context division is achieved using Sequential K-Means Clustering online; 2) Knowledge distillation. The knowledge distillation loss (L D ) is incorporated into the objective function (L ori ) to avoid interference among contexts due to the shared feature extractor; 3) Joint optimization with a multihead neural network, which aims to estimate the value for each (s, a, ω(s)) with the joint optimization loss (L = L ori + λL D ). Here, to keep consistency with the random encoder introduced later, we also call the representation module of the neural network as "RL Encoder". In summary, our method can improve the performance by decoupling the correlations among differently distributed states and intentionally preserving the learned policies.
understand the states of different distributions, we define a variable ω for a set of states that are close to each other in the state space, referred to as "context". Formally, where Ω is a finite set of contexts and k is the number of contexts. For an arbitrary MDP, we partition its state space into k contexts, and all states within each context follow approximately the same distribution, to decouple the correlations among states against distribution drift. More precisely, for a partition of S in Eq. (6), we associate a context ω i with each set S i , so that for s ∈ S i , ω(s) = ω i , where ω(s) can be thought of as a function of state s. The inherent learning-while-exploring feature of RL agents leads to the fact that the agent generally does not experience all possible states of the environment while searching for the optimal policy. Thus, it is unnecessary to process the entire state space. Based on this fact, in IQ, we only perform context division on states experienced during training. In this paper, we employ Sequential K-Means Clustering [29] (See Appendix A-A) to achieve context detection adaptively.
In Fig. 3, k centroids C = {c 1 , c 2 , . . . , c k } are initialized at random in the entire state space. In each subsequent time step t, we execute State Assignment and Centroid Update steps for each incoming state received from the environment 4 , and store its corresponding transition {s t , ω(s t ), a t , r t , s t+1 , ω(s t+1 )} into the replay buffer B. Accordingly, in the training phase, we 4 Note that it is suggested to normalize the state in different dimensions before performing these two steps for more reasonable context division results. randomly sample a batch of transitions from B and train the shared feature extractor Φ R and the specific output head Φ A corresponding to the input state simultaneously, while conducting fine-tuning of other output heads to avoid interference on learned policies. Since we store the context label of each state in the replay buffer, there are no additional state assignments required at every update step 5 .
Note that it is also possible to conduct context division based on the initial state distribution [50]. By contrast, we show that the partition of all states experienced during training can produce more accurate and effective context division results, as the trajectories starting from the initial states within different contexts have a high likelihood of overlapping in subsequent time steps (See Appendix A-B for more details).
Interference Among Contexts: We investigate the interference among contexts obtained by our context division method in details. Specifically, we measure the Huber loss of TD errors in different contexts of the game as the agent learns in other contexts, and then record the relative changes in loss before and after the agent's learning, as shown in Fig. 4. The results show that, long-term training on any context may lead to negative generalization on all other contexts, even in such simple RL task CartPole-v0. The results on Pendulum-v0 shown in Appendix A-C also support the same conclusion.
Computational Complexity: Assuming a d-dimensional environment of k contexts, the time and space complexities of our proposed context division module to process T environment steps are O(T kd) and O(kd), respectively.

B. Knowledge Distillation
The shared low-level representation can cause the learning in new contexts to interfere with previous learning results, leading to catastrophic interference. A relevant technique to address this issue is knowledge distillation [38], which works well for encouraging the outputs of one network to approximate the outputs of another. The concept of distillation was originally used to transfer knowledge from a complex ensemble of networks to a relatively simpler network to reduce model complexity and facilitate deployment. In IQ, we use it as a regularization term in value function estimation to preserve the previously learned information.
When training the model on a specific context, we need to consider two aspects of the loss function: the general loss of the current training context (denoted by L ori ), and the distillation loss of other contexts (denoted by L D ). The former encourages the model to adapt to the current context to ensure plasticity, while the latter encourages the model to keep the memory of other contexts, preventing interference.
To incorporate IQ into the DQN framework, we rewrite the original loss function of DQN in Eq. (3) with the context variable ω as: where is the estimated target value of Q(s, a, ω(s); θ S , θ T ) and µ is the distribution of samples, i.e., {s, ω(s), a, r, s , ω(s )} ∼ µ, and L refers to the Huber loss. For each of the other contexts that the environment contains, we expect the output value for each pair of (s, a) to be close to the recorded output from the original network. In knowledge distillation, we regard the learned Q-function before the current update step as the teacher network, expressed as Q i t = Q(s, a, ω i ; θ − S , θ − F ), and the current network to be trained as the student network, expressed as Q i s = Q(s, a, ω i ; θ S , θ F ), where ω i ∈ Ω except the current context ω(s). Thus, the distillation loss is defined as: where Algorithm 1 IQ: Interference-aware Deep Q-learning Input: Initial replay buffer B with capacity |B| = N ; Initial Q-function f θ with random weights θ; Initial targetQ-function f θ − with weights θ − = θ; Initial context centroids C = {c 1 , c 2 , . . . , c k }; Initial target context centroidsĈ = C. Parameter: Total training steps T , the number of contexts k, target update period C, learning rate α. Output: Updated C and f θ .
1: Initial state s; 2: for t = 1, T do 3: Interact with environment to obtain {s t , a t , r t , s t+1 }.

8:
Reset θ − = θ andĈ = C every C training steps. 9: end for is the distillation loss function of the output head corresponding to context ω i .

C. Joint Optimization Procedure
To optimize a Q-function that can guide the agent to make proper decisions on each context without being adversely affected by catastrophic interference, we combine Eqs. (7) and (9) to form a joint optimization framework. Namely, we solve the catastrophic interference problem by the following optimization objective: where λ ∈ [0, 1] is a coefficient to control the trade-off between the stability and plasticity of the neural network. The complete procedure is described in Algorithm 1. The proposed method performs the context division in parallel to the training process without requiring additional data. For network training, to reduce the correlations with the target and ensure the stability of model training, the target network parameter θ − is only updated by the Q-network parameter θ every C steps and is held fixed between individual updates, as in DQN [5]. Similarly, we also adopt fixed target context centroids (Ĉ) to avoid a small amount of instability of states assignment step introduced by constantly updated context centroids (C). To simplify the model implementation, we set the updating frequency of the target context centroids to be consistent with the target network.

D. Random Encoders for High-dimensional State Space
For high-dimensional state spaces, we propose to use random encoders for efficient context division, which can map high-dimensional inputs into low-dimensional representation spaces, overcoming the "curse of dimensionality". Although the original RL model already contains an encoder module, it is constantly updated and directly performing clustering in its representation space may introduce extra instability into context division. Therefore, on the basis of IQ, we exploit a dedicated random encoder module for dimension reduction. Fig. 5 gives an illustration of this updated framework called IQ-RE in which the structure of the random encoder f θre is consistent with the underlying RL encoder, but its parameter θ re is randomly initialized and fixed throughout training. We provide the full procedure of IQ-RE in Appendix B-B.
The main motivation of using random encoders arises from the observation that distances in the representation space of random encoder are adequate for finding similar states without any representation learning [32]. That is, the representation space of a random encoder can effectively capture the information about the similarity among states without any representation learning (See Appendix B-A). Additional comparative experiments of IQ with the random encoder and the underlying RL trained encoder in Appendix B-B further highlight the superiority of random encoders.

V. EXPERIMENTS AND EVALUATIONS
In this section, we conduct comprehensive experiments on several standard benchmarks from OpenAI Gym 6 containing 4 classic control tasks and 6 high-dimensional complex Atari games to demonstrate the effectiveness of our method.

A. Datasets
Classic Control [53] contains 4 classic control tasks: CartPole-v0, Pendulum-v0, CartPole-v1, Acrobot-v1, where the dimensions of state spaces are in the range of 3 to 6. The maximum time steps are 200 for CartPole-v0 and Pendulum-v0, and 500 for CartPole-v1 and Acrobot-v1. Meanwhile, the reward thresholds used to determine tasks solved are 195.0, 475.0 and −100.0 for CartPole-v0, CartPole-v1 and Acrobot-v1, respectively, while that for Pendulum-v0 is not yet specified. We choose these commonly used domains as they are well-understood and relatively simple, suitable for highlighting the mechanism and verifying the effectiveness of our method in a straightforward manner.
Atari Games [33] contain 6 image-level complex tasks: Pong, Breakout, Carnival, Freeway, Tennis, FishingDerby, where the observation is the screenshot represented by an RGB image of size 210 × 160 × 3. We choose these domains to further demonstrate the scalability of our method on highdimensional complex tasks that present significant challenges for existing baseline methods.

B. Implementation
Network Structure. For the 4 classic control tasks, we employ a fully-connected layer as the feature extractor and a fully-connected layer as the multi-head action scorer, following the network configuration for this type of tasks in OpenAI Baseline. For the 6 Atari games, we employ the similar convolution neural network as [44], [54] for feature extracting and two fully-connected layers as the multi-head action scorer. More details can be found in Appendix C.
Parameter Setting. In IQ, there are two key parameters: λ and k. To simplify parameter setting, we set λ in accordance with the exploration proportion in all experiments: λ = 1− , due to the inverse relationship between them in training. In the early training, is close to 1, and the model is normally inaccurate with little interference, and a small λ (close to 0) can promote plasticity construction of the model. Then, gradually approaches 0 during the subsequent training, and the model has learned more useful information, while interference is also likely to occur. Consequently, smoothly increasing λ is needed to ensure plasticity while avoiding interference. Meanwhile, we set k to 3 for all classic control tasks, and 4 for all Atari games. In IQ-RE, we set the extra parameter d to 50 as in [32], which has been shown to be both efficient and effective. Other parameter settings can be found in Appendix C. For classic control tasks, we evaluate the training performance using the average episode returns every 10K time steps for CartPole-v0, Pendulum-v0, and 20K time steps for CartPole-v1, Acrobot-v1. For Atari games, the time step range for performance evaluation is 200K. All experiment results reported are the average episode returns over 5 independent runs.

C. Baselines
We evaluate our method in comparison to following stateof-the-art baseline methods for single-task RL: which reduces catastrophic interference using experience replay and fixed target networks. We use the DQN agent implemented in OpenAI Baselines. • Rainbow [44] is the upgraded version of DQN containing six extensions, including a prioritized replay buffer [27], n-step returns [2], Adam optimizer [55] and distributional learning [10] for stable RL training. The Rainbow agent is implemented in Google's Dopamine framework 7 [54]. • SRNN [26] employs a distributional regularizer to induce sparse representations in neural networks to avert catastrophic interference in the single-task RL. Here, we implement it in the form of fully online training. • DSOM [25] introduces a DSOM module to control the activation of the representation output layer to achieve local optimization. We reproduce it with reference to the original DSOM implementation 8 . • TCNN [21] aims to remap the inputs to a higherdimensional space using tile coding to sparsify the input features, reducing activation overlap. We adopt its implementation in [56]. In the experiments, we firstly use DQN as the underlying RL method to evaluate the effectiveness of IQ in comparison to all baselines on classic control tasks. We then extend them to high-dimensional Atari games to further validate the scalability of IQ. Note that TCNN suffers from scalability issues for benchmarks with high dimensionality as it increases the dimension of input to the neural network, and DSOM has not been applied to solve any high-dimensional RL tasks in [25], whose implementation details are unclear. Therefore, we evaluate IQ-RE only in comparison to DQN and SRNN on the Atari games. Additionally, we also implement IQ-RE with Rainbow, to illustrate that our method is highly flexible and can be incorporated into various existing value-based RL models.

D. Evaluation Metrics
Following the convention in previous studies [9]- [11], [24], [44], we employ the average training episode returns R T to evaluate our method during training: where M is the number of episodes experienced within each evaluation period; J i is the total time steps in episode i; R ij is the reward received at time step j in episode i.

E. Results
To address the effectiveness of our proposed method, we present primary results of IQ incorporated with DQN and all baselines implemented on 4 control tasks. Fig. 6 shows the learning curves of average episodic return during training for each task with three levels of replay buffer capacity, and Table I reports the numerical results in terms of the highest cumulative return achieved in corresponding curves.
In general, IQ is clearly superior to all baselines both in terms of the stability and the maximum achieved cumulative reward, especially when the replay buffer capacity is small (e.g., N = 100) or even without experience replay (i.e., N = 1). In most tasks, IQ achieves near optimal performance as well as good stability even without any experience replay. For Pendulum-v0 and Acrobot-v1, a large replay buffer (e.g., N = 50, 000) can help DQN, SRNN and TCNN escape from catastrophic interference. However, this is not the case for two CartPole tasks where the agents exhibit fast initial learning but then encounter collapse in performance. DSOM performs comparably to IQ with large replay buffers, but is significantly inferior to IQ with the other two smaller capacities. We also conduct experimental comparisons with all baselines in terms of the degree of interference (according to Eq. (5)), corresponding to all task settings in Fig. 6. The experimental results are presented in Appendix D-A, from which we can further confirm that IQ can substantially reduce the negative interference encountered by the base RL agents during the learning progress.
Moreover, from a macro perspective, Fig. 6 shows that: 1) DQN, SRNN and TCNN agents exhibit high sensitivity to the replay buffer capacity. They generally perform well with a large buffer (except on CartPole-v1), but their performance deteriorates significantly when the buffer capacity is reduced. The reason for this phenomenon is that DQN primarily relies on experience replay to obtain approximately i.i.d. training data to avoid possible interference in training, which cannot be guaranteed when the replay buffer capacity is small. Since SRNN just reshapes the constraint term on the basis of DQN loss, while TCNN only increases the input dimension of DQN, both techniques can only alleviate interference to a certain extent. 2) The overall performance of DSOM is better than the above three baselines, as it optimizes the data distributionspecific representation modules to circumvent the interference caused by the shared representation layer. Nevertheless, since DSOM shares the same output layer, it still suffers from interference on most tasks. 3) By contrast, IQ features a shared representation module and multiple data distributionspecific output heads, and employs the knowledge distillation technique to prevent interference caused by shared representation layers, achieving significantly better performance than baselines. Note that in some cases (e.g., CartPole-v1 settings), IQ learns more slowly than baselines during the early stages of training. A possible explanation is that IQ learns context division in a fully online manner and the partitions may not be accurate enough back then, but it can quickly surpass the baselines as the training progress.
Additionally, to demonstrate the scalability and flexibility of our method, we also provide the results of IQ-RE with DQN and Rainbow separately, on 6 Atari games. The learning curves are shown in Fig. 7 and the highest cumulative returns achieved during training are summarized in Table II. Overall, for high-dimensional image inputs, the training performance of the underlying RL algorithms can be noticeably improved with our IQ-RE scheme, while SRNN provides little contribution to both underlying RL methods. Specifically, in Fig. 7, with DQN as the underlying RL method, IQ-RE significantly outperforms DQN and SRNN on 7 out of 12 tasks, being comparable with DQN and SRNN on the rest 5 tasks. Similarly, with Rainbow as the underlying RL method, IQ-RE outperforms baselines on 8 out of 12 tasks, while being comparable with baselines on the rest 4 tasks. The two-sample Kolmogorov-Smirnov test in Appendix D-C further confirms that the improvement brought by IQ-RE is statistically significant. Furthermore, as shown in Table II, IQ-RE achieves higher maximum cumulative scores in most tasks than its counterparts. Among the 24 training settings, the maximum cumulative scores achieved by IQ-RE are slightly lower than those of baselines in only 4 cases and 2 cases when combined with DQN and Rainbow, respectively. It is worth noting that, even with a large memory (N = 1, 000, 000), IQ-RE still shows certain advantages over the baselines.
In summary, the proposed techniques containing context division based on the clustering of all experienced states, and knowledge distillation in multi-head neural networks can effectively eliminate catastrophic interference caused by data drift in the single-task RL, whilst reduce the requirement of the replay buffer capacity for off-policy RL. In addition, our method leverages a fixed randomly initialized encoder to characterize the similarity among states in the low-dimensional representation space, which can be used to partition contexts effectively for high-dimensional environments.
F. Analysis 1) Ablation Study: Since our method can be regarded as an extension to existing RL methods (e.g., DQN [5]), with three novel components (i.e., adaptive context division by online clustering, knowledge distillation, and the multi-head neural network), the ablation experiments are designed as follows: • No clustering means using a random partition of the raw state space before learning instead of adaptive context  division by online clustering. • No distillation means removing the distillation loss function L D (θ S , θ F ) from Eq. (11) (i.e., λ = 0). • No multi-head means removing the context division module and optimize the neural network with a singlehead output (i.e., k = 1). Here, the distillation term is represented as the distillation of the network before each update of the output head.
The results of ablation experiments are shown in Fig. 8, using classic control tasks for the convenience of validation. From Fig. 8, the following facts can be observed: 1) Across all settings, the overall performance of DQN is the worst, showing the effectiveness of the three components introduced for coping with catastrophic interference in the single-task RL, although the contribution of each component varies substantially per task; 2) Removing online clustering from the context division module is likely to damage the performance in most cases; 3) Removing knowledge distillation makes the performance deteriorate on almost all tasks, indicating that knowledge distillation is a key element in our method; 4) Without the multi-head component, our model is equivalent to a DQN with an extra distillation loss, which performs better than DQN alone but worse than our proposed IQ in general. Note that, on Pendulum-v0, the single-head network performs better than our method during training, which means that the additional distillation constraint is sufficient to mitigate the interference faced by the base RL under this setting, without the need of further context division. By contrast, our method learns context division in a fully online manner and the partitions may not be accurate enough on this task. However, this is not the case in other settings (See Appendix D-E for more experimental results).
2) Context Division Strategy: By introducing the context variables during learning, IQ bears a resemblance to some existing settings [47], [50] that partition contexts using game score and initial states. Therefore, we further compare our  context division based on all experienced states with the following context division strategies: • Game Score [47] splits a game into contexts based on the undiscounted cumulative game score. • Initial States [50] partitions the initial state space into "slices" by the k-means clustering procedure.
From the experimental results in Fig. 9, we can observe that our method is distinctly superior to the above two strategies in general, although it performs slightly worse on Pendulum-v0. This is due to the fact that, on Pendulum-v0, the game scores or initial states have a perfect correspondence to different state distributions. However, these two baselines are primarily designed to decompose complex tasks, rather than mitigating catastrophic interference in the single-task RL settings and cannot guarantee the complete decoupling among different state distributions. This conclusion is further confirmed by the additional experimental results in Appendix D-F.
3) Parameter Analysis: There are two critical parameters in IQ: λ and k. By its nature, λ is related to the training progress. Since we need to preserve the learned good policies during training, it is intuitive to gradually increase λ until its value reaches 1. The reason is that, in early-stage training, the model has not learned any sufficiently useful information, so the distillation constraint can be ignored. With the progress of training, the model starts to acquire more and more valuable information and needs to pay serious attention to interference to protect the learned good policies while learning further. In our experiments, we recommend to set λ to be inversely proportional to the exploration proportion , and the results in Figs. 6 and 7 have demonstrated the simplicity and effectiveness of this setting.
For the parameter k, it needs to be specified before training, which may be suboptimal without a good knowledge of the state space structure of the environment. To investigate the effect of k, we conduct experiments with different k values (k ∈ {1, 2, 3, 4, 5}) and the results are shown in Fig. 10. In our experiments, k = 3 is a reasonably good choice for CartPole- v0 and CartPole-v1, while k = 5 is best for IQ on Acrobot-v1.
It is worth noting that, on Pendulum-v0, our method achieves similar performance with k set to 2, 3, 4, and 5, respectively, but without any satisfactory result. A possible explanation is that the agents failed to learn any useful information due to the limited exploration in the early training, leading to the failure of further learning. In summary, we can make the following statements: 1) The performance of our method is obviously better than the base RL baseline regardless of the specific k value, confirming the effectiveness of IQ even with inaccurate k estimation; 2) For k > 1, better performance of IQ can be expected. However, large k values are not always desirable as it will result in more fine-grained context divisions and more complex neural networks with a large amount of output heads, making the model unlikely to converge satisfactorily within a limited number of training steps. Thus, we recommend to set the value of k by taking into consideration the state-space structure of specific tasks. In practice, we recommend to explore the Here, we only take into account forward and backward passes through neural network layers (See Fig. 7 for corresponding learning curves). environment using an appropriate random policy and conduct initial density-based clustering for the obtained states before training. Thereafter, the initial centroids of SKM and k value can be estimated according to this initial clustering result. 4) Convergence Analysis: To analyze convergence, we track the agent's average loss and average predicted action-value during training progress. According to Fig. 11, we can conclude that: 1) Our method has better convergence and stability in face of interference compared with original RL algorithms (See Figs. 11(a) and 11(b)); 2) For a held-out set of states 9 , the average maximum predicted action-value of each output head reflects the difference as expected (See Fig. 11(c)), and the final output of IQ is synthesised based on all of them. 5) Computational Efficiency: Our methods greatly improve training performance of the existing RL algorithms, which are computationally efficient in that: 1) In each time step, the extra context division module only needs to compute the distances between the current state and k context centroids, which is computationally negligible w.r.t. the SGD complexity of the large parameter vector updated in each iteration of RL itself; 2) Only k −1 extra output heads are added to the neural network, in which the increased computation is acceptable w.r.t. the representation complexity; 3) There are no gradient updates through the random encoder; 4) There is no unnecessary distance computation for finding the corresponding context at every update step as the context label for each state is stored in the replay buffer. Fig. 12 shows the training time of each agent on Pendulum and the floating point operations (FLOPs) executed by agents on Breakout, respectively.

VI. CONCLUSION AND FUTURE WORK
In this paper, we propose a competent scheme IQ to tackle the inherent challenge of catastrophic interference in the single-task RL. The core idea is to partition all states experienced during training into a set of contexts using online clustering techniques and simultaneously estimate the contextspecific value function with a multi-head neural network as well as a knowledge distillation loss to mitigate the interference across contexts. Furthermore, we introduced a random encoder to enhance the context division for high-dimensional complex tasks. Our method can effectively decouple the correlations among differently distributed states and can be easily incorporated into various value-based RL models. Experiments on several benchmarks show that our method can significantly outperform state-of-the-art RL methods and dramatically reduce the memory requirement of existing RL methods.
In the future, we aim to incorporate our method into policybased RL models to reduce the interference during training by applying weight or functional regularization on policies. Furthermore, we will investigate a more challenging setting called continual RL in non-stationary environments [46]. This setting is a more realistic representation of the real-world scenarios and includes abrupt changes or smooth transitions on dynamics, or even the dynamics itself is shuffled.

APPENDIX A ILLUSTRATION OF CONTEXT DIVISION A. Sequential K-Means Clustering
The process of Sequential K-Means Clustering for the current state s is shown in Algorithm 2. Each context centroid c i is the average of all of the states s closest to c i . In order to get a better initialization of C, we can perform offline K-Means clustering on all states experienced before training starts and set the results of centroids as the initial C. Then, Sequential K-Means Clustering is performed in subsequent time steps.

B. Initial States vs All Experienced States
We compare the effects of two kinds of context division techniques: • ISC (Initial States Clustering) means performing context division using K-Means on the samples sampled from the initial states distribution, referring to [50]; • ESC (Experienced States Clustering) is our proposed method that performs context division using Sequential K-Means Clustering on all states experienced during training process. We run the DQN agent incorporated with IQ with the above two clustering techniques on CartPole-v0, respectively, and visualize the two-dimensional t-SNE results of context division in Fig. 13. It can be clearly observed that the contexts divided by ESC are relatively independent and there is almost no overlapping area among contexts, achieving effective decoupling among states with different distributions. By contrast, there are obvious overlapping areas among the contexts divided by Algorithm 3 IQ-RE: Interference-aware Deep Q-learning with Random Encoder Input: Initial replay buffer B with capacity N ; Initial Q-function f θ with random weights θ; Initial targetQ-function f θ − with weights θ − = θ; Initial random encoder f θre with weights θ re ; Initial context centroids C = {c 1 , c 2 , . . . , c k }; Initial target context centroidsĈ = C. Parameter: Total training steps T , the number of contexts k, the output dimension of random encoder d, target update period C, learning rate α. Output: Updated C and f θ .
1: Initial state s; 2: for t = 1, T do 3: Interact with environment to obtain {s t , a t , r t , s t+1 }.

9:
if t mod C == 0 then Here, N is set to 10, 000. The solid lines and shaded regions represent the mean and standard deviation, respectively, across five runs. In summary, the performance of IQ with the random encoder is significantly better than that of IQ with the underlying RL trained encoder.
ISC, since the trajectories starting from the initial states within different contexts have a high likelihood of overlapping in subsequent time steps, which is not desirable for reducing interference on neural network training among differently distributed states. . This result is obtained using the same experimental setup and method as for CartPole-v0 in Fig. 4, and we can draw a completely consistent conclusion with that in Fig. 4.  16. Two-dimensional t-SNE visualization of K-nearest neighbors of states found by measuring distances in the representation space of a Random Encoder on Breakout. We observe that the representation space of a randomly initialized encoder effectively captures information about similarity between states.

C. Interference Among Contexts on Pendulum-v0
Similar to Fig. 4, we further investigate the interference among contexts obtained by our context division method on Pendulum-v0, and the result is shown in Fig. 15. The conclusion obtained from this additional experimental result is consistent with that in Fig. 4.

A. Representation Space Visualization of Random Encoder
To verify the feature that the random encoder can preserve the distance similarity of input samples, We find the K-nearest neighbors of some specific states by measuring the distances in the low-dimensional representation space produced by a randomly initialized encoder (Random Encoder) on Breakout. The results are shown in Fig. 16 from which we can observe that the raw images corresponding to the K-nearest neighbors of the source image in the representation space of the random encoder demonstrate significant similarities.

B. Random Encoder vs. RL Trained Encoder
For high-dimensional complex state spaces, a simple and intuitive idea is to perform clustering on the low-dimensional representation space of the underlying RL trained encoder directly. However, the RL trained encoder is constantly updated during learning, which means that the low-dimensional output results corresponding to the same input may be different with the progress of learning. Therefore, clustering based on the RL trained encoder is likely to bring extra inaccuracy and instability into context division. To complement the above analysis, additional experiments are conducted on two Atari games Breakout and Carnival. With the underlying RL trained encoder and the randomly initialized encoder respectively using two base RL algorithms (i.e., DQN and Rainbow), and the results are shown in Fig. 14. Furthermore, the numbers of FLOPs executed by both agents on Breakout are reported in Table III. Compared with the RL trained encoder, IQ with the randomly initialized encoder achieves distinctly better performance with only about 2% overhead. The full procedure of IQ with random encoder (named IQ-RE) is shown in Algorithm 3.

APPENDIX C IMPLEMENTATION DETAILS A. Implementation Details for the Underlying RL Model
To ensure the fairness of comparison, our results compare the agents based on the underlying RL model with the same hyperparameters and neural network architecture. We provide a full list of neural networks architecture of the underlying RL models in Table IV and summarize our choices for common key hyperparameters in Table V.

B. Implementation Details for All Other Methods
In our method and all baseline methods, the part of the underlying RL model follows the aforementioned network architecture and hyperparameter settings, and the methodspecific parameter settings are summarized as follows: • SRNN: the sparsity level β is set to 0.1, and the coefficient λ KL of distributional regularizes is also set to 0.1 for all tasks; • DSOM: the DSOM learning rate is set to 0.25, the elasticity η is set to 1.0, κ is set to 0.5, and the number of DSOM weight vectors is set to 64 for all classic control tasks; • TCNN: it uses binning operation to turn each raw input variable to 20 binary variables, and the results of all classic control tasks are generated with a single tiling; • IQ: the coefficient λ of distillation loss term is set in accordance with the exploration proportion of the agent in all tasks: λ = 1 − , the number k of context to be divided is set to 3 for all classic control tasks and 4 for all Atari games, and the output dimension of random encoder d is set to 50 for all Atari games.

A. Measuring Interference
We show a comparison in terms of Approximate Expected Interference (AEI, referring to Eq. (5)) in this section. Fig. 17 records the negative interference generated after each iteration during the training process of each agent, where all curves correspond to the learning curves in Fig. 6, respectively. In our experiments, we approximated in Eq. (5) with a buffer containing recent transitions of capacity 10K, keeping the settings being same as that in Fig. 2. It should be noted that, to demonstrate the interference caused by each model iteration more clearly and intuitively, we only show the negative interference in each update step, that is, all update steps in which the losses on recent 10K transitions increase after updating the model.
From Fig. 17, we can see that the interference curves corresponding to IQ (red curves) are are below those corresponding to all other baselines in almost all task settings. Therefore, we can further confirm that our proposed scheme IQ does indeed  Fig. 6 for corresponding learning performance curves). In principle, IQ does indeed significantly alleviates the negative interference encountered by the base RL agents during learning progress.
dramatically reduce the catastrophic interference commonly encountered by the existing basic RL methods, and outperform to other baselines for interference mitigation during learning in the single RL task settings.

B. Additional Experimental Results on MountainCar
We conduct additional performance evaluation experiments on MountainCar with sparse reward. The reward threshold used to determine the success of MountainCar is −110.0. In our experiments, the episode terminates if it takes more than 1000 steps. All implementation details, including network architecture and parameter settings, are exactly the same as those in CartPole-v1 and Acrobot-v1, except additional reward shaping. We reshape the reward for each time step based on potentials by referring to the solution 10 on the task leadboard 11 . In addition, we add an extra bonus of 100 when the car reaches the target position. The results in Fig. 18 demonstrate the consistent superiority of IQ over the baseline methods as shown in Fig. 6.
C. Two-Sample Kolmogorov-Smirnov Test Results for Fig. 7 We performed a two-sample Kolmogorov-Smirnov test on the area under the learning curves reported in Fig. 7.

D. Statistics of the Maximum Deterioration Ratios
In order to further investigate the maximum degradation degree of the performance during model training, the maximum   deterioration ratios compared to the previous maximal episode returns are given in Table VII. From which, we can see that IQ-RE achieves less performance degradation in most tasks compared to its counterparts. Under a small buffer setting (N = 10, 000), DQN and Rainbow incorporated with IQ-RE surpass the original RL methods by 3.4% and 2.2%, respectively, and exceed that combined with SRNN by 1.1% and 10.8%, respectively. Note that, even with a large memory (N = 1, 000, 000), IQ-RE still shows certain advantages over the baselines.

E. Additional Results of Ablation Experiments
We provide additional experimental results of IQ incorporated with DQN and three different ablations on four classic control tasks with N = 1 in Fig. 19. Overall, all three ablations do improve the performance of DQN, but are still not comparable to IQ that combines all components. Those results are consistent with the analysis about ablation study in Section V-F.

F. Additional Results of Context Division Strategy
We show additional experimental results of the comparison to other two context division strategies (i.e., context division based on game score or initial state space) under N = 50, 000 and N = 1 settings in Fig. 20, which further confirm the effectiveness of our proposed context division strategy based on all experienced states during learning.

APPENDIX E CALCULATION OF MODEL COMPLEXITY
Computational Complexity of Context Division. At each time step, SKM only needs to calculate the distances between the current state and k context centroids. Given a ddimensional state space and T -step environment interactions, the time complexity of context division is O(T kd). At the same time, since only k additional context centroids need to be stored for clustering, the space complexity is O(kd).
Calculation of Floating Point Operations. We obtain the number of operations per forward pass for all layers in the 2bI(E + kM ) + 2bI(E + kM ) + T (E + kM ) + T E where b is the batch size; T is the number of environment steps; I is the number of training updates. The first two terms are for the forward and backward passes required in training updates, respectively. The latter two terms are for the forward passes required to compute the policy action and obtain the low-dimensional representation from the random encoder, respectively. In our experiments: b = 32, T = 1e7, I = 0.25e7, k = 4, E = 28.582 MFLOPs, M = 3.420 MFLOPs for Rainbow and 3.215 MFLOPs for DQN.