L EARNING G ENERALIZABLE R EPRESENTATIONS FOR R EINFORCEMENT L EARNING VIA A DAPTIVE M ETALEARNER OF B EHAVIORAL S IMILARITIES
A BSTRACT
How to learn an effective reinforcement learning-based model for control tasks from high-level visual observations is a practical and challenging problem.
A key to solving this problem is to learn low-dimensional state representations from observations, from which an effective policy can be learned.
In order to boost the learning of state encoding, recent works are focused on capturing behavioral similarities between state representations or applying data augmentation on visual observations.
In this paper, we propose a novel meta-learner-based framework for representation learning regarding behavioral similarities for reinforcement learning.
Specifically, our framework encodes the high-dimensional observations into two decomposed embeddings regarding reward and dynamics in a Markov Decision Process (MDP).
A pair of meta-learners are developed, one of which quantifies the reward similarity and the other quantifies dynamics similarity over the correspondingly decomposed embeddings.
The meta-learners are self-learned to update the state embeddings by approximating two disjoint terms in on-policy bisimulation metric .
To incorporate the reward and dynamics terms, we further develop a strategy to adaptively balance their impacts based on different tasks or environments.
We empirically demonstrate that our proposed framework outperforms state-of-the-art baselines on several benchmarks, including conventional DM Control Suite, Distracting DM Control
Suite and a self-driving task CARLA.
I NTRODUCTION
Designing effective reinforcement learning algorithms for learning to control from high-dimensional visual observations is crucial and has attracted more and more attention (Yarats et al., 2021;
Laskin et al., 2020a; Schwarzer et al., 2021; Lesort et al., 2018).
To learn a policy efficiently from highdimensional observations, prior approaches first learn an encoder to map high-dimensional observations, e.g., images, to low-dimensional representations, and subsequently train a policy from low-dimensional representations to actions based on various RL algorithms.
Therefore, how to learn low-dimensional representations, which are able to provide semantic abstraction for high-dimensional observations, plays a key role.
Early works on deep reinforcement learning train encoders based on various reconstruction losses (Lange & Riedmiller, 2010;
Watter et al., 2015; Wahlstr¨om et al., 2015; Higgins et al., 2017), which aim to enforce the learned low-dimensional representations to reconstruct the original high-dimensional observations after decoding.
Promising results have been achieved in some application domains, such as playing video games, simulated tasks, etc.
However, the policy learned on state representations trained with a reconstruction loss may not generalize well to complex environments, which are even though semantically similar to the source environment.
The reason is that a reconstruction loss is computed over all the pixels, which results in all the details of the high-dimensional images tending to be preserved in the low-dimensional representations.
However, some of the observed details, such as complex background objects in an image, are task-irrelevant and highly environment-dependent.
Encoding such details in representation learning makes the learned representation less effective for a downstream reinforcement learning task of interest and less generalizable to new environments.
To address the aforementioned issue, some data augmentation techniques have been proposed to make the learned representations more robust (Yarats et al., 2021;
Lee et al., 2020b; Laskin et al., 2020b).
However, these approaches rarely consider the properties of a
Markov Decision Process (MDP), such as conditional transition probabilities between states given an action, in the representation learning procedure.
Recent research (Zhang et al., 2021; Agarwal et al., 2021; Castro, 2020; Ferns et al., 2004) has shown that the bisimulation metric and its variants are potentially effective to be exploited to learn a more generalizable reinforcement learning agent across semantically similar environments.
The bisimulation metric measures the “behavioral similarity” between two states based on two terms: 1) reward difference that considers the difference in immediate task-specific reward signals between two states, and 2) dynamics difference that considers the similarity of the long-term behaviors between two states.
A general idea of these approaches is to learn an encoder to map observations to a latent space such that the distance or similarity between two states in the latent space approximates their bisimulation metric.
In this way, the learned representations (in the latent space) are task-relevant and invariant to environmental details.
However, manually specifying a form of distance, e.g., the Lnorm as used in (Zhang et al., 2021), in the latent space may limit the approximation precision for the bisimulation metric and potentially discard some state information that is useful for policy learning.
Moreover, existing approaches rarely explore how to learn an adaptive combination of reward and dynamics differences in the bisimulation metric, which may vary in different tasks or environments.
We propose a novel framework for learning generalizable state representations for RL, named Adaptive Meta-learner of Behavioral Similarities (AMBS).
In this framework, we design a network with two encoders that map the high-dimensional observations to two decomposed representations regarding rewards and dynamics.
For the purpose of learning behavioral similarity on state representations, we introduce a pair of meta-learners that learn similarities in order to measure the reward and the dynamics similarity between two states over the corresponding decomposed state representations, respectively.
The meta-learners are self-learned by approximating the reward difference and the dynamics difference in the bisimulation metric.
Then the meta-learners update the state representations according to their behavioral distance to the other state representations.
Previous approaches with a hand-crafted form of distance/similarity evaluating state encoding in the L 1 space are difficult to minimize the approximation error for the bisimulation metric, which may lead to important side information being discarded, e.g., information regarding to Q-value but not relevant to states distance/similarity. Instead, our learned similarities measure two states representations via a neural architecture, where side information can be preserved for policy learning.
Our experiments also showed that a smaller approximation loss for similarity learning can be obtained by using the meta-learners.
This demonstrates that the proposed meta-learners can overcome the approximation precision issue introduced by the L 1 distance in previous approaches and provide more stable gradients for robust learning of state representations for deep RL.
Moreover, we explore the impact between the reward and the dynamics terms in the bisimulation metric.
We propose a learning-based adaptive strategy to balance the effect between reward and dynamics in different tasks or environments by introducing a learnable importance parameter, which is jointly learned with the state-action value function.
Finally, we use a simple but effective data augmentation strategy to accelerate the RL procedure and learn more robust state representations.
The main contributions of our work are 3-fold: 1) we propose a meta-learner-based framework to learn task-relevant and environment-details-invariant state representations; 2) we propose a network architecture that decomposes each state into two different types of representations for measuring the similarities in terms of reward and dynamics, respectively, and design a learnable adaptive strategy to balance them to estimate the bisimulation metric between states; 3) we verify our proposed framework on extensive experiments and demonstrate new state-of-the-art results on backgrounddistraction DeepMind control suite (Tassa et al., 2018;
Zhang et al., 2018; Stone et al., 2021) and other visual-based RL tasks.
R ELATED W ORK
Representation learning for reinforcement learning from pixels Various existing deep RL methods have been proposed to address the sample-efficiency and the generalization problems for conventional RL from pixel observation.
In end-to-end deep RL, neural networks learn representations implicitly by optimizing some RL objective (Mnih et al., 2015; Espeholt et al., 2018).
Watter et al.
(2015) and Wahlstr¨om et al.
(2015) proposed to learn an encoder with training a dynamics model jointly to produce observation representations.
Lee et al.
(2020a), Hafner et al.
, Hafner et al.
(2020) and Zhang et al.
(2019) aimed to learn an environment dynamics model with the reconstruction loss to compact pixels to latent representations.
Gelada et al.
(2019) proposed to learn representations by predicting the dynamics model along with the reward, and analyzed its theoretical connection to the bisimulation metric.
Agarwal et al.
(2021) proposed to learn representations by state distances based on policy distribution.
Kemertas & Aumentado-Armstrong (2021) modified the learning of bisimulation metric with intrinsic rewards and inverse dynamics regularization.
Castro et al.
(2021) replaced the Wasserstein distance in bisimulation metric with a parametrized metric.
Data Augmentation in reinforcement learning Laskin et al. (2020b) and Ye et al.
(2020b) explored various data augmentation techniques for deep RL, which are limited to transformations on input images.
Cobbe et al.
(2019) applied data augmentation to domain transfer.
Ye et al.
(2020a) studied data augmentation on game environments for zero-shot generalization.
RandConv (Lee et al., 2020b) proposed a randomized convolutional neural network to generate randomized observations in order to perform data augmentation.
A recent work DrQ (Yarats et al., 2021) performs random crop on image observations and provides regularized formulation for updating Q-function.
Raileanu et al.
(2021) proposed to use data augmentation for regularizing on-policy actor-critic RL objectives.
Pitis et al.
(2020) proposed a counterfactual data augmentation technique by swapping observed trajectory pairs.
P RELIMINARIES
We define an environment as a Markov Decision Process (MDP) described by a tuple M =
( S , A , P , R , γ ) , where S is the high-dimensional state space (e.g., images), A is the action space,
P ( s ′ | s , a ) is the transition dynamics model that captures the probability of transitioning to next state s ′ ∈ S given current state s ∈ S and action a ∈ A , R is the reward function yielding a reward signal r =
R ( s , a ) ∈ R , and γ ∈ [0 , 1) is the discounting factor.
The goal of reinforcement learning is to learn a policy π ( a | s ) that maximizes the expected cumulative rewards: max π E [ (cid:80) t γ t r ( s t , a t ) | a t ∼ π ( ·| s t ) , s ′ t ∼ P ( s ′ | s , a )] .
In the scope of this paper, we do not consider partial observability, and use stacked consecutive frames as the fully observed states.
Soft Actor-Critic (SAC) is a widely used off-policy model-free reinforcement learning algorithm (Haarnoja et al., 2018).
SAC aims to maximize the entropy objective (Ziebart, 2010) which is the reinforcement learning objective augmented with an entropy term J ( π )
= (cid:80) t E [ r ( s t , a t ) + α H ( π ( ·| s t ))] .
In order to maximize the objective, SAC learns a state-value function Q θ ( s , a ) , a stochastic policy π ψ ( a | s ) and the temperature α , where θ and ψ are the parameters of
Q θ and π ψ , respectively.
The Q-function is trained by minimizing the squared soft Bellman residual
[Equation]
where D is the dataset or replay buffer storing the transitions, and V ¯ θ is the value function parameterized by ¯ θ .
The parameters ψ of policy is learned by maximizing the following objective
[Equation]
The Bisimulation Metric defines a pseudometric d : S × S
→ R , 1 where d quantifies the behavioral similarity of two discrete states (Ferns et al., 2004).
An extension to both continuous and discrete state spaces has also been developed (Ferns et al., 2011).
A variant of the bisimulation metric proposed in Castro (2020) defines a metric w.r.t. a policy π , which is known as the on-policy bisimulation metric.
It removes the requirement of matching actions in the dynamics model but focuses on the policy π , which is able to better capture behavioral similarity for a specific task.
Because of this property, in this paper, we focus on the π -bisimulation metric (Castro, 2020):
[Equation]
where R π s := (cid:80) a π ( a | s ) R ( s , a ) and P π s := (cid:80) a π ( a | s ) P ( ·| s , a ) . The mapping F π : met → met , where met denotes the set of all pseudometrics in state space S and W 1 ( d )( · , · ) denotes the 1Wasserstein distance given the pseudometric d .
Then F π has a least fixed point denoted by d ∗ .
Deep
[Figure]
Bisimulation for Control (DBC) (Zhang et al., 2021) is to learn latent representations such that the Ldistances in the latent space are equal to the π -bisimulation metric in the state space:
[Equation]
where ϕ is the state encoder, and W 2 ( d )( · , · ) denotes the 2-Wasserstein distance.
DBC is combined with the reinforcement learning algorithm SAC, where ϕ ( s ) is the input for SAC.
A DAPTIVE M ETA - LEARNER OF B EHAVIORAL S IMILARITIES
In this section, we propose a framework named Adaptive Meta-learner of Behavioral Similarities (AMBS) to learn generalizable states representation regarding the π -bisimulation metric.
The learning procedure is demonstrated in Figure 1.
Observe that the π -bisimulation metric is composed of two terms: |R π s i −
R π s j | , which computes the difference of rewards between states, and W 2 ( d )( P π s i , P π s j ) , which computes the difference of the outputs of dynamics model between states.
We propose a network architecture which contains encoders to transform the high-dimensional visual observations to two decomposed encodings regarding rewards and dynamics.
We develop two meta-learners, one of which quantifies the reward difference on reward representations and the other captures dynamics distance (Section 4.1).
Each meta-learner is self-learned to update the corresponding state representations by learning to approximate a term in the π -bisimulation metric, respectively.
Rather than enforcing the L 1 distance between embedded states to be equal to the π -bisimulation metric, our meta-learners are able to use a more flexible form of similarity, i.e., a well-designed non-linear neural network, with each similarity evaluates the reward difference or dynamics difference between states beyond the original Euclidean space.
Moreover, we propose a strategy for learning to combine the outputs of the two learned similarities in a specific environment (Section 4.2).
We introduce a learnable weight for the combination and such weight is adaptively learned together with the policy learning procedure (in this work we use SAC as the base reinforcement learning algorithm).
In addition, we also use a data augmentation technique to make the learned representations more robust (Section 4.3).
The whole learning procedure is trained in an end-to-end manner.
4. M ETA - LEARNERS FOR D ECOMPOSED R EPRESENTATIONS
We design a network architecture with two encoders, ϕ r and ϕ d , to encode decomposed features from visual observations as shown in the left side of Figure 1.
Each encoder maps a high-dimensional observation to a low-dimensional representation, i.e., ϕ r : S → Z r capturing reward-relevant features and ϕ d : S → Z d capturing dynamics-relevant features.
We design two meta-learners, f r and f d , where f r learns to measure reward difference and f d aims to measure dynamics difference between two state representations.
Specifically, each meta-learner takes two embedded states as input and outputs the corresponding similarity.
The procedure is summarized as follows.
[Equation]
[Equation]
where ∗ ∈ { r, d }
[Equation]
Note that the aggregation of the outputs of the two encoders ϕ r and ϕ d of each observation (i.e., state)is also fed into SAC to learn a policy (the right side of Figure 1).
Each self-learned metalearner learns to capture similarity by approximating a distance term in the π -bisimulation metric, respectively, and provides stable gradients for updating ϕ r or ϕ d according to the distance to the other state representations.
The details of network architecture can be found in Appendix B.2.
As discussed in Section 1, restricting the form of distance to be the L 1 / L 2 norm in the latent space may limit the approximation precision.
As shown in Figure 2, the L 1 and the L 2 norm for measuring the distance of two latent representations ϕ
( s i ) and ϕ ( s j ) lead to large regression losses during RL training, which destabilize the representation learning and consequently decrease final performance.
Besides, such hand-crafted distances make semantically similar states encoding close to each other in terms of the L 1 norm in Euclidean space, which however may lose part of useful information, e.g., policy-relevant information but not immediately regarding to the distance.
To overcome the aforementioned limitations, we propose to exploit meta-learners f r and f d to learn similarities.
By learning with a regression target, the similarity learned by f ∗ is easier to converge to the target and leads to faster descent tendency of regression loss (as shown in Figure 2 where y-axis is log-scale).
Such a property provides more stable gradients for state representation comparing to the L 1 / L 2 norm, and therefore the meta-learner f ∗ is able to guide the process of updating the state encoder.
Besides, f ∗ is a non-linear transformation that evaluates the state similarity in a more flexible space instead of the original Euclidean space. Consequently, it is able to preserve more task-relevant information in state representation that is required for further SAC policy learning.
As the goal of meta-learners is to approximate different types of similarities in the π -bisimulation metric, we design the loss functions for the meta-learners using the mean squared error:
[Equation]
To make the resultant optimization problems compatible with SGD updates with transitions sampled from replay buffer, we replace the reward metric term
|R π s i −
R π s j | by the distance of rewards in the sampled transitions in (4), and use a learned parametric dynamics model ˆ P to approximate the true dynamics model
P π s in (5).
We also use 2-Wasserstein distance W 2 in (5) (as in DBC) because it has a closed form for
Gaussian distributions.
Denote by ( s i , a i , r i , s ′ i ) and ( s j , a j , r j , s ′ j ) two transitions sampled from the replay buffer. The loss functions (4) and (5) can be revised as follows,
[Equation]
where ˆ P ( ·| ϕ d ( s ∗ ) , a ∗ ) is a learned probabilistic dynamics model, which is implemented as a neural network that takes the dynamics representation ϕ d ( s ∗ ) and an action a ∗ as input, and predicts the distribution of dynamics representation of next state s ′∗ .
The details of ˆ P can be found Appendix A.
4. B ALANCING I MPACT OF R EWARD AND D YNAMICS
The π -bisimulation metric (3) is defined as a linear combination of the reward and the dynamics difference.
Rather than considering the combination weight as a hyper-parameter, which needs to be tuned in advance, we introduce a learnable parameter c ∈ (0 , 1) to adaptively balance the impact of the reward and the dynamics in different environments and tasks.
As the impact factor c should be automatically determined when learning in a specific task or environment, we integrate the learning of c into the update of the Q-function in SAC such that the value of c is learned from the state-action value which is highly relevant to a specific task and environment.
To be specific, we concatenate the low-dimensional representations ϕ r ( s ) and ϕ d ( s ) weighted by 1 − c and c , where 1 − c and c are output of a softmax to ensure c ∈ (0 , 1) .
The loss for the Q-function is revised as follows, which takes ϕ r ( s ) , ϕ d ( s ) , weight c and action a as input:
[Equation]
where Q θ is the Q-function parameterized by θ and V ( · ) is the target value function.
Moreover, to balance the learning of the two meta-learners f r and f d , we jointly minimize the regression losses of f r and f d ((6) and (7), respectively) with the balance factor c .
Thus, the loss function is modified as follows,
[Equation]
Note that c is already learned along with the Q-function, we stop gradient of c when minimizing the loss (9).
This is because if we perform gradient descent w.r.t.
c , it may only capture which loss ( ℓ ( f r , ϕ r ) or ℓ ( f d , ϕ d ) ) is larger/smaller and fail to learn the quantities of their importance.
We also stop gradient for the dynamics model ˆ P since ˆ P only predicts one-step dynamics.
4. O VERALL O BJECTIVE WITH D ATA A UGMENTATION
In this section, we propose to integrate a data augmentation strategy into our proposed framework to learn more robust state representations.
We follow the notations of an existing work on data augmentation for reinforcement learning, DrQ (Yarats et al., 2021), and define a state transformation h : S × T → S that maps a state to a data-augmented state, where T is the space of parameters of h .
In practice, we use a random crop as the transformation h in this work.
Then T contains all possible crop positions and v ∈ T is one crop position drawn from T .
We apply DrQ to regularize the objective of the Q-function (see Appendix for the full objective of Q-function).
Besides, by using the augmentation transformation h , we rewrite the loss of representation learning and similarity approximation in (9) as follows,
[Equation]
+
[Equation]
[Table]
where s ( k ) ∗
= h ( s ∗ , v ( k ) ∗ ) is the transformed state with parameters v ( k ) ∗ .
Specifically, s (1) i , s (1) j , s (2)
i and s (2) j are transformed states with parameters of v (1) i , v (1) j , v (2) i and v (2)
j respectively, which are all drawn from T independently.
The first two terms in (10) are similar to the two terms in (9), while the observation s ∗ in (9) is transformed to s (1) ∗ .
For the last two terms in (10), the observation is transformed by a different parameter v (2) ∗ except for the last term, where the parameter v (1) ∗ does not change.
The reason why the parameter v (1) ∗ is used in the last term is that we expect the meta-learner f d is able to make a consensus prediction on s (1) ∗ and s (2) ∗ as they are transformed from a same state s ∗ .
Another major difference between the first two terms and the last two terms is the order of the subscripts i and j : i is followed by j in first two terms while j is followed by i in last two terms.
The reason behind this is that we aim to make f r and f d to be symmetric.
The loss of the actor of SAC, which is based on the output of the encoder, is
[Equation]
where ˆ ϕ denotes the convolutional layers of ϕ and Q θ ( ϕ ( s ) , a ) is a convenient form of the Q-function with c -weighted state representations input.
We also stop gradients for ˆ ϕ and ϕ ( ϕ r and ϕ d ) regarding the actor loss.
In other words, the loss in (11) only calculates the gradients w.r.t.
ψ .
The overall learning algorithm is summarized in Algorithm 1.
Note that due to limit of space, more details can be found in Appendix A.
In summary, as illustrated in Figure 1, in AMBS, the convnet is shared by the encoders ϕ r and ϕ d , which consists of 4 convolutional layers.
The final output of the convnet is fed into two branches: 1) one is a fully-connected layer to form reward representation ϕ r ( s ) , and 2) the other is also a fully-connected layer but forms dynamics representation ϕ d ( s ) .
The meta-learners f r and f d are both MLPs with two layers.
More implementation details are provided at Appendix B. Source code is available at https://github.com/jianda-chen/AMBS .
E XPERIMENTS
The major goal of our proposed AMBS is to learn a generalizable representation for RL from high-dimensional raw data.
We evaluate AMBS on two environments: 1) the DeepMind Control (DMC) suite (Tassa et al., 2018) with background distraction; and 2) autonomous driving task on CARLA (Dosovitskiy et al., 2017) simulator.
Several baselines methods are compared with AMBS: 1)
Deep Bisimulation Control (DBC) (Zhang et al., 2021) which is recent research on RL representation learning by using the L 1 distance to approximate bisimulation metric; 2) PSEs (Agarwal et al., 2021) which proposes a new state-pair metric called policy similarity metric for representation learning and learns state embedding by incorporating a contrastive learning method SimCLR (Chen et al., 2020); 3) DrQ (Yarats et al., 2021), a state-of-the-art data augmentation method for deep RL; 4) Stochastic
Latent Actor-Critic (SLAC)
(Lee et al., 2020a), a state-of-the-art approach for partial observability on controlling by learning a sequential latent model with a reconstruction loss; 5) Soft Actor-Critic (SAC) (Haarnoja et al., 2018), a commonly used off-policy deep RL method, upon which above baselines and our approach are built.
5. DMC SUITE WITH BACKGROUND DISTRACTION
DeepMind Control (DMC) suite (Tassa et al., 2018) is an environment that provides high dimensional pixel observations for RL tasks.
DMC suite with background distraction (Zhang et al., 2018; Stone et al., 2021) replaces the background with natural videos which are task-irrelevant to the RL tasks.
We perform the comparison experiments in two settings: original background and nature video background.
For each setting we evaluate AMBS and baselines in 4 environments, cartpoleswingup, finger-spin, cheetah-run and walker-walk.
Results of additional environments are shown in Appendix D.
[Figure]
Original Background.
Figure 3a shows the DMC observation of original background which is static and clean.
The experiment result is shown in Figure 4.
Our method AMBS has comparable learning efficiency and converge scores comparing to state-of-the-art pixel-level RL methods DrQ and SLAC.
Note that DBC performs worse in original background setting.
Natural Video Background.
Figure 3b shows the DMC observation with natural video background.
The background video is sampled from the Kinetics (Kay et al., 2017) dataset under label “driving car”.
By following the experimental configuration of DBC, we sample 1,000 continuous frames as background video for training, and sample another 1,000 continuous frames for evaluation.
The experimental result is shown in Figure 5.
Our method AMBS outperforms other baselines in terms of both efficiency and scores.
It converges to the scores that are similar to the scores on original background setting within 1 million steps.
DrQ can only converge to the same scores on cartpoleswingup and finger-spin but the learning is slightly slower than AMBS.
The sequential latent model method SLAC performs badly on this setting.
This experiment demonstrates that AMBS is robust to the background task-irrelevant information and the AMBS objectives improve the performance when comparing to other RL representation learning methods, e.g., DBC.
5. A BLATION S TUDY
Our approach AMBS consists of several major components: meta-learners, a factor to balance the impact between reward and dynamics, and data augmentation on representation learning.
To evaluate the importance of each component, we eliminate or replace each component by baseline methods.
We conduct experiments on cheetah-run and walker-walk under the natural video background setting.
Figure 6 shows the performance of AMBS, variants of AMBS and baseline methods.
AMBS w/o data aug is constructed by removing data augmentation in AMBS.
AMBS w/o f is referred to as replacing the meta-learners f r and f d by the L 1 distance, as in DBC.
AMBS w/o c removes the component of balancing impact between reward and dynamics but encodes the observation into a single embedding.
It uses single meta-learner to approximate the sum of reward and dynamics distance.
DBC + DrQ is DBC with data augmentation applied on representation learning and SAC.
AMBS c = 0 .
5 denotes AMBS with a fixed weight c = 0 .
AMBS w/ (1 , γ ) replaces c in AMBS by freezing the reward weight to 1 and the dynamics weight to γ .
Such a setting of weights is used in DBC.
Figure 6 demonstrates that AMBS performs better than any of its variant.
Comparing to DBC that does not utilize data augmentation, our variant AMBS w/o data aug still performs better.
This comparison shows that using meta-learners f r and f d to learn reward- and dynamicsrelevant representations is able to improve RL performance compared with using the L 1 distance to approximate the whole π -bisimulation metric.
5. T RANSFER OVER R EWARD F UNCTIONS
The environments walker-walk, walker-run and walker-stand share the same dynamics but have different reward functions according to the moving speed.
To evaluate the transfer ability of AMBS over reward functions, we transfer the learned model from walker-walk to walker-run and walkerstand.
We train agents on walker-run and walker-stand with frozen convolutional layers of encoders that are well trained in walker-walk.
The experiments are done under the natural video setting compared with DBC as shown in Figure 7.
It shows that the transferring encoder converges faster than training from scratch.
Besides our approach has a better transfer ability than DBC.
5. G ENERALIZATION OVER B ACKGROUND V IDEO
We evaluate the generalization ability of our method when background video is changed.
We follow the experiment setting of PSE (Agarwal et al., 2021)n.
We pick 2 videos, ‘bear’ and ‘bmx-bumps’, from the training set of DAVIS 2017 (Pont-Tuset et al., 2018) for training.
We randomly sample one video and a frame at each episode start, and then play the video forward and backward until episode ends.
The RL agent is evaluated on validation environment where the background video is sampled from validation set of DAVIS 2017.
Those validation videos are unseen during the training.
The evaluation scores at 500K environment interaction steps is shown in Table 1.
The comparison method DrQ+PSEs is data augmented by DrQ. AMBS outperforms DrQ+PSEs on all the 4 tasks.
It demonstrates that AMBS is generalizable on unseen background videos.
[Table]
[Figure]
5. A UTONOMOUS D RIVING T ASK ON CARLA
CARLA is an autonomous driving simulator that provides a 3D simulation for realistic on-road scenario.
In real world cases or in realistic simulation, the learning of RL agents may suffer from complex background that contains task-irrelevant details.
To argue that AMBS can address this issue, we perform experiments with CARLA.
We follow the setting of DBC to create an autonomous driving task on map “Town04” for controlling a car to drive as far as possible in 1,000 frames.
The environment contains a highway with 20 moving vehicles.
The reward function prompts the driving distance and penalizes collisions.
The observation shape is 84 × 420 pixels which consists of five 84 ×cameras.
Each camera has 60 degrees view, together they produce a 300 degrees first-person view, as shown in Figure 8.
The weather, clouds and brightness may change slowly during the simulation.
Figure 9 shows the training curves of AMBS and other comparison methods.
AMBS performs the best, which provides empirical evidence that AMBS can potentially generalize over task-irrelevant details, e.g., weather and clouds, in real world scenarios.
C ONCLUSION
This paper presents a novel framework AMBS with meta-learners for learning task-relevant and environment-detail-invariant state representation for deep RL.
In AMBS, we propose state encoders that decompose an observation into rewards and dynamics representations for measuring behavioral similarities by two self-learned meta-learners, and design a learnable strategy to balance the two types of representations.
AMBS archives new state-of-the-art results in various environments and demonstrates its transfer ability on RL tasks.
Experimental results verify that our framework is able to effectively learn a generalizable state representation.
A CKNOWLEDGEMENT
A O BJECTIVES OF A DAPTIVE M ETA - LEARNER OF B EHAVIORAL S IMILARITIES (AMBS)
We denote two encoders ϕ r and ϕ d , where each encoder maps a high-dimensional observation to a low-dimensional representation.
The encoder ϕ r : S → Z r captures reward-relevant features and the encoder ϕ
d : S → Z d captures dynamics-relevant features, where Z r and Z d are representation spaces.
We design two meta-learners f r :
Z r × Z r → R and f d : Z d × Z d → R to output reward difference and dynamics difference, respectively.
We follow DrQ (Yarats et al., 2021) to define the state transformation h : S × T → S that maps a state to a data-augmented state, where T is the space of parameters of h .
In practice, we use random crop as transformation h .
With augmentation transformation h , the loss of representation learning is,
[Equation]
[Equation]
where Θ = { f r , f d , ϕ r , ϕ d } , s ( l ) ∗
= h ( s ∗ , v ( l ) ∗ ) is the transformed state with parameters v ( l ) ∗ .
Specifically, s (1) i , s (1) j , s (2)
i and s (2) j are transformed states with parameters of v (1) i , v (1) j , v (2) i and v (2)
j respectively, which are all drawn from T independently.
ˆ P ( ·| ϕ d ( s ∗ ) , a ∗ ) is a learned probabilistic dynamics model, which outputs a Gaussian distribution over Z d for predicting dynamics representation of next state s ′∗ .
W 2 denotes the 2-Wasserstein distance which has closed-form for Gaussian distributions: W 2 ( N ( µ i , Σ i ) , N ( µ j , Σ j )) 2 = ∥ µ
i − µ j ∥ 22 + ∥ Σ 12 i − Σ 12 j ∥ 2 F , where µ ∗ ∈ R |Z
d | are the mean vectors of Gaussian distribution,
Σ ∗ ∈ R |Z
d | are the diagonals of covariance matrices, and ∥ · ∥ F is Frobenius norm.
Note that we stop gradients for c as mentioned in Section 4.2.
The adaptive weight c and (1 − c ) are the softmax output of corresponding learnable parameter η c ∈ R 2 .
It can be formulated as
[Equation]
13) where the operation : denotes concatenation of two vectors/scalars,
We integrate the learning of c into the update of Q-function of SAC.
The objective of the Q-function with DrQ augmentation and clipped double trick is
[Equation]
where s ( l ) =
h ( s , v ( l ) ) , v ( l ) are all drawn from T independently, and { Q θ k } 2 k =1 are the double Q networks.
The target value function with DrQ augmentation is
[Equation]
[Equation]
where s ′ ( l )
=
h ( s ′ , v ′ ( l ) ) , a ′ ( l ) ∼ π ψ ( a ′ ( l ) | s ′ ( l ) ) , ¯ θ k is the set of parameters of the target Q network, ¯ ϕ r and ¯ ϕ d are target encoders specifically for the target Q network and ¯ c is the adaptive weight for target encoders.
The parameters ¯ θ k , ¯ ϕ r , ¯ ϕ d and ¯ η c are softly updated.
The loss of actor of SAC is,
[Equation]
The loss of α of SAC is,
[Equation]
where ¯ H ∈ R is the target entropy hyper-parameter which in practice is ¯ H = −|A| .
The loss for updating of dynamics model ˆ P is
[Equation]
where µ ( ˆ P ( · )) and σ ( ˆ P ( · )) are mean and standard deviation of ˆ P output Gaussian distribution, respectively.
Algorithm 2 shows the algorithm at each learning step.
Algorithm 2 AMBS+SAC
+ (1 − τ ϕ )¯ η c .
B I MPLEMENTATION D ETAILS B. P IXELS P ROCESSING
We stack 3 consecutive frames as observation, where each frame is 84 × 84 RGB images in DeepMind control suite.
Each pixel is divided by 255 to down scale to [0 , 1] .
We consider the stacked frames as fully observed state.
B. N ETWORK A RCHITECTURE
We share the convnet for encoder ϕ r and encoder ϕ d .
The shared convnet consists of four convolutional layers with 3 × 3 kernels and 32 output channels.
We set stride to 1 everywhere, except for the first convolutional layer, which has stride 2.
We use ReLU activation for each convolutional layer output.
The final output of convnet is fed into two branches: 1) one is a fully-connected layer withdimensions to form reward representation ϕ r ( s ) , and 2) the other one is also a fully-connected layer with 50 dimensions but form dynamics representation ϕ d ( s ) .
The meta-learners f r and f d are both
MLPs with two layers with 50 hidden dimensions.
The critic network takes ϕ r ( s ) , ϕ d ( s ) and action as input, and feeds them into three stacked fullyconnected layers with 1024 hidden dimensions.
The actor network takes the shared convnet output as input, and feeds it into four fully-connected layers where the first layer has 100 hidden dimensions and other layers have 1024 hidden dimensions.
The dynamics model is MLPs with two layers with 512 hidden dimensions.
ReLU activations are used in every hidden layer.
B. H YPERPARAMETERS
The hyperparameters used in our algorithm are listed in Table 2. [Table]
B. A CTION R EPEAT FOR DMC
We use different action repeat hyper-parameters for each task in DeepMind control suite, which are listed in Table 3.
[Table]
B. S OURCE C ODES
Source code of AMBS is available at https://github.com/jianda-chen/AMBS .
C A NALYSIS C. R EGRESSION L OSSES OF A PPROXIMATING B ISIMULATION M ETRIC
We compare the regression losses of approximating the bisimulation metric over RL environment steps among DBC and our AMBS.
DBC uses the L 1 norm to calculate the distances between two states embeddings.
AMBS performs meta-learners on state representations to measure the distance with learned similarities.
Figure 10 demonstrates that AMBS has smaller regression loss and also faster descent tendency compared to DBC.
Meta-learners in AMBS are able to provide more stable gradients to update the state representations.
C. V ISUALIZATIONS OF C OMBINATION W EIGHT C
Figure 11 shows the values of combination weight c in AMBS trained on DMC with origin background and Figure 11 is on DMC with video background setting.
The values of c at 1M steps vary in different tasks.
The common trend is that they increase at the beginning of training.
In original background setting c changes slowly after the beginning.
In natural video background setting , c has a fast drop after the beginning.
In the beginning, agent learns a large weight c for dynamics feature that may boost the learning of RL agent.
Then it drops for natural video background setting because it learns that the video background is distracting the agent.
Lower weight is learned for the dynamics features.
environment steps
C. N ORMS OF S TATE E MBEDDINGS
We record the L 1 norms of reward representation
ϕ r ( s ) and dynamics representation ϕ d ( s ) during training.
We record 1 n r || ϕ r ( s ) || 1 for reward representation where n r is the number of dimensions of ϕ r ( s ) , and 1 n d || ϕ d
( s ) || 1 for dynamics representation where n r is the number of dimensions of ϕ d ( s ) .
Figure 13 shows the values averaged on each sampled training batch.
Although the L 1 norm of ϕ d ( s ) decreases during training, it converges around 0.4-0.5.
The L 1 norm of ϕ r ( s ) also decreases in the training procedure.
It can verify that dynamics representation ϕ d ( s ) will not converge to all zeros.
C. S HARING E NCODERS B ETWEEN A CTOR AND
C RITIC
In AMBS, we share only the convolutional layers ˆ ϕ of encoders between actor and critic network.
We compare to sharing the whole encoders ϕ r and ϕ d in this experiment.
Figure 14 shows the raining curves on Walker-Walk with natural video background.
Sharing full encoder ϕ r and ϕ d is worse than sharing only CNN ˆ ϕ .
D A DDITIONAL E XPERIMENTAL R ESULTS D. A DDITIONAL R ESULT OF DMC S UITE WITH AND W / O B ACKGROUND D ISTRACTION
Figure 15 shows the training curves on original background setting.
Figure 16 shows the training curves on Kinetics (Kay et al., 2017) video background setting.
D. A DDITIONAL R ESULT OF G ENERALIZATION OVER B ACKGROUND V IDEO
Table 4 shows the scores on DAVIS video background setting comparing to PSEs (Agarwal et al., 2021).
[Table]
D. A DDITIONAL R ESULT ON CARLA
The CARLA experiment is to learn an autonomous driving RL agent to avoid collisions with other moving vehicles and drive as far as possible on a highway within 1000 frames.
Those vehicles are randomly generated, including vehicles’ types, colors and initial positions.
We raise the number of generated vehicles from 20 to 40 so that the road becomes more crowded for RL agent.
Besides, we also extend the training steps to 2e5 for AMBS and DBC.
Figure 17 shows the training curve on
CARLA.
AMBS and DBC run on the precious setting of CARLA, while AMBS40 and DBC40 run on the highway with 40 generated vehicles.
When increasing the number of vehicles from 20 to 40,
DBC becomes more difficult to learn but AMBS is just slightly slower.
DBC still doesn’t achieve high scores after 1e5 steps.
E P ROOFS E. V ALUE - FUNCTION B OUND
Theorem E.1 (Value function difference bound for different discounting factors (Petrik & Scherrer, 2009; Kemertas & Aumentado-Armstrong, 2021)) .
Consider two identical MDPs except for different discounting factors γ 1 and γ 2 , where γ 1 ≤ γ 2 and reward r ∈ [0 , 1] .
Let V πγ denotes the value function for MDP with discounting factor γ given policy π .
[Equation]
Definition E.1 ( c -weighted on policy bisimulation metric) .
Given a policy π , and c ∈ (0 , 1) , the on-policy bisimulation metric exists,
[Equation]
Theorem E.2 (Value difference bound) .
For any c ∈ [ γ, 1) , given two state s i and s j ,
[Equation]
proof.
Lemma 6 of Kemertas & Aumentado-Armstrong (2021).
Theorem E.3 (Generalized value difference bound) .
For any c ∈ (0 , 1) , given two states s i and s j ,
[Equation] [Equation]
proof.
We follow the proof of Theorem 1 in Kemertas & Aumentado-Armstrong (2021).
Suppose another MDP with discounting factor γ ′ =
c exists.
From Theorem E.2 we have
[Equation]
Then,
[Equation]
Replace γ ′ by c , finally we have
[Equation]