Mask-based Latent Reconstruction for Reinforcement Learning
Abstract
For deep reinforcement learning (RL) from pixels, learning effective state representations is crucial for achieving high performance.
However, in practice, limited experience and high-dimensional inputs prevent effective representation learning.
To address this, motivated by the success of mask-based modeling in other research fields, we introduce mask-based reconstruction to promote state representation learning in RL.
Specifically, we propose a simple yet effective self-supervised method, Mask-based Latent Reconstruction (MLR), to predict complete state representations in the latent space from the observations with spatially and temporally masked pixels.
MLR enables better use of context information when learning state representations to make them more informative, which facilitates the training of
RL agents.
Extensive experiments show that our MLR significantly improves the sample efficiency in RL and outperforms the state-of-the-art sample-efficient RL methods on multiple continuous and discrete control benchmarks.
Our code is available at https://github.com/microsoft/Mask-based-Latent-Reconstruction.
Introduction
Learning effective state representations is crucial for reinforcement learning (RL) from visual signals (where a sequence of images is usually the input of an RL agent), such as in DeepMind Control Suite [52], Atari games [5] etc .
Inspired by the success of mask-based pretraining in the fields of natural language processing (NLP) [12, 42, 43, 8] and computer vision (CV) [4, 25, 58], we make the first endeavor to explore the idea of mask-based modeling in RL.
Mask-based pretraining exploits the reconstruction of masked word embeddings or pixels to promote feature learning in NLP or CV fields.
This is, in fact, not straightforwardly applicable for RL due to the following two reasons.
First, RL agents learn policies from the interactions with environments, where the experienced states vary as the policy network is updated.
Intuitively, collecting additional rollouts for pretraining is often costly especially in real-world applications.
Besides, it is challenging to learn effective state representations without the awareness of the learned policy.
Second, visual signals usually have high information densities, which may contain distractions and redundancies for policy learning.
Thus, for RL, performing reconstruction in the original (pixel) space is not as necessary as it is in the CV or NLP fields.
Based on the analysis above, we study the mask-based modeling tailored to vision-based RL.
We present Mask-based Latent Reconstruction (MLR), a simple yet effective self-supervised method, to better learn state representations in RL.
Contrary to treating mask-based modeling as a pretraining task in the fields of CV and NLP, our proposed MLR is an auxiliary objective optimized together with the policy learning objectives.
In this way, the coordination between representation learning and policy learning is considered within a joint training framework.
Apart from this, another key difference compared to vision/language research is that we reconstruct masked pixels in the latent space instead of the input space.
We take the state representations ( i .
e ., features) inferred from original unmasked frames as the reconstruction targets.
This effectively reduces unnecessary reconstruction relative to the pixel-level one and further facilitates the coordination between representation learning and policy learning because the state representations are directly optimized.
Consecutive frames are highly correlated.
In MLR, we exploit this property to enable the learned state representations to be more informative, predictive and consistent over both spatial and temporal dimensions.
Specifically, we randomly mask a portion of space-time cubes in the input observation ( i .
e ., video clip) sequence and reconstruct the feature representations of the missing contents in the latent space.
In this way, similar to the spatial reconstruction for images in [25, 58], MLR enhances the awareness of the agents on the global context information of the entire input observations and promotes the state representations to be predictive in both spatial and temporal dimensions.
The global predictive information is encouraged to be encoded into each frame-level state representation, achieving better representation learning and further facilitating policy learning.
We not only propose an effective mask-based modeling method, but also conduct a systematical empirical study for the practices of masking and reconstruction that are as applicable to RL as possible.
First, we study the influence of masking strategies by comparing spatial masking, temporal masking and spatial-temporal masking.
Second, we investigate the differences between masking and reconstructing in the pixel space and in the latent space.
Finally, we study how to effectively add reconstruction supervisions in the latent space.
Our contributions are summarized below:
• We introduce the idea of enhancing representation learning by mask-based modeling to RL to improve the sample efficiency.
We integrate the mask-based reconstruction into the training of RL as an auxiliary objective, obviating the need for collecting additional rollouts for pretraining and helping the coordination between representation learning and policy learning in RL.
• We propose Mask-based Latent Reconstruction (MLR), a self-supervised mask-based modeling method to improve the state representations for RL.
Tailored to RL, we propose to randomly mask space-time cubes in the pixel space and reconstruct the information of missing contents in the latent space .
This is shown to be effective for improving the sample efficiency on multiple continuous and discrete control benchmarks ( e
g ., DeepMind Control Suite [52] and Atari games [5]).
• A systematical empirical study is conducted to investigate the good practices of masking and reconstructing operations in MLR for RL.
This demonstrates the effectiveness of our proposed designs in the proposed MLR.
Related Work 2.1 Representation Learning for RL
Reinforcement learning from visual signals is of high practical value in real-world applications such as robotics, video game AI, etc .
However, such high-dimensional observations may contain distractions or redundant information, imposing considerable challenges for RL agents to learn effective representations [48].
Many prior works address this challenge by taking advantage of selfsupervised learning to promote the representation learning of the states in RL.
A popular approach is to jointly learn policy learning objectives and auxiliary objectives such as pixel reconstruction [48, 61], reward prediction [27, 48], bisimulation [64], dynamics prediction [48, 16, 33, 34, 46, 63], and contrastive learning of instance discrimination [32] or (spatial -) temporal discrimination [40, 2, 49, 65, 38].
In this line, BYOL [15]-style auxiliary objectives, which are often adopted with data augmentation, show promising performance [46, 63, 59, 22, 17].
More detailed introduction for BYOL and the BYOL-style objectives can be found in Appendix A.3.
Another feasible way of acquiring good representations is to pretrain the state encoder to learn effective state representations for the original observations before policy learning.
It requires additional offline sample collection or early access to the environments [23, 49, 37, 36, 47], which is not fully consistent with the principle of sample efficiency in practice.
This work aims to design a more effective auxiliary task to improve the learned representations toward sample-efficient RL.
2.2 Sample-efficient Reinforcement Learning
Collecting rollouts from the interaction with the environment is commonly costly, especially in the real world, leaving the sample efficiency of RL algorithms concerned.
To improve the sample efficiency of vision-based RL ( i .
e ., RL from pixel observations), recent works design auxiliary tasks to explicitly improve the learned representations [61, 32–34, 65, 35, 46, 62, 63] or adopt data augmentation techniques, such as random crop/shift, to improve the diversity of data used for training [60, 31].
Besides, there are some model-based methods that learn (world) models in the pixel [67] or latent space [19–21, 62], and perform planning, imagination or policy learning based on the learned models.
We focus on the auxiliary task line in this work.
2.3 Masked Language/Image Modeling
Masked language modeling (MLM) [12] and its autoregressive variants [42, 43, 8] achieve significant success in the NLP field and produce impacts in other domains.
MLM masks a portion of word tokens from the input sentence and trains the model to predict the masked tokens, which has been demonstrated to be generally effective in learning language representations for various downstream tasks.
For computer vision (CV) tasks, similar to MLM, masked image modeling (MIM) learns representations for images/videos by pretraining the neural networks to reconstruct masked pixels from visible ones.
As an early exploration, Context Encoder [41] apply this idea to Convolutional
Neural Network (CNN) model to train a CNN model with a masked region inpainting task.
With the recent popularity of the Transfomer-based architectures, a series of works [10, 4, 25, 58, 57] dust off the idea of MIM and show impressive performance on learning representations for vision tasks.
Inspired by MLM and MIM, we explore the mask-based modeling for RL to exploit the high correlation in vision data to improve agents’ awareness of global-scope dynamics in learning state representations.
Most importantly, we propose to predict the masked information in the latent space , instead of the pixel space like the aforementioned MIM works, which better coordinates the representation learning and the policy learning in RL.
Approach 3.1 Background
Vision-based RL aims to learn policies from pixel observations by interacting with the environment.
The learning process corresponds to a partially observable Markov decision process (POMDP) [7, 28], formulated as ( O , A , p, r, γ ) , where O , A , p , r and γ denote the observation space ( e .
g ., pixels), the action space, the transition dynamics p
=
Pr ( o t +1 | o ≤ t , a t ) , the reward function O ×
A → R , and the discount factor, respectively.
Following common practices [39], an observation o t is constructed by a few RGB frames.
The transition dynamics and the reward function can be formulated as p t =
Pr ( o t +1 | o t , a t ) and r t = r
( o t , a t ) , respectively.
The objective of RL is to learn a policy π ( a t | o t ) that maximizes the cumulative discounted return E π (cid:80) ∞ t =
γ t r t , where γ ∈ [0 , 1] .
3.2 Mask-based Latent Reconstruction
Mask-based Latent Reconstruction (MLR) is an auxiliary objective to promote representation learning in vision-based RL and is generally applicable for different RL algorithms, e .
g .
, Soft Actor-Critic (SAC) and Rainbow [26].
The core idea of MLR is to facilitate state representation learning by reconstructing spatially and temporally masked pixels in the latent space.
This mechanism enables better use of context information when learning state representations, further enhancing the understanding of RL agents for visual signals.
We illustrate the overall framework of MLR in Figure 1 and elaborate on it below.
Framework.
In MLR, as shown in Figure 1, we mask a portion of pixels in the input observation sequence along its spatial and temporal dimensions.
We encode the masked sequence and the original sequence from observations to latent states with an encoder and a momentum encoder, respectively.
We perform predictive reconstruction from the states corresponding to the masked sequence while taking the states encoded from the original sequence as the target.
We add reconstruction supervisions between the prediction results and the targets in the decoded latent space.
The processes of masking , encoding , decoding and reconstruction are introduced in detail below.
𝑀𝑀𝑀𝑀𝑀𝑀𝑀𝑀 ( � ) 𝒐𝒐 𝑡𝑡
𝒐𝒐 𝑡𝑡+
𝒐𝒐 𝑡𝑡+2 𝒐𝒐 𝑡𝑡+3 𝒐𝒐 𝑡𝑡+𝐾𝐾−1 �𝒐𝒐 𝑡𝑡 �𝒐𝒐 𝑡𝑡+1 �𝒐𝒐 𝑡𝑡+2 �𝒐𝒐 𝑡𝑡+
�𝒐𝒐 𝑡𝑡+𝐾𝐾− 𝐴𝐴𝐴𝐴𝐴𝐴 ( � ) 𝑂𝑂𝑂𝑂𝑂𝑂𝑂𝑂𝑂𝑂𝑂𝑂 𝐸𝐸 𝑂𝑂𝐸𝐸 𝐸𝐸𝐸𝐸 𝑂𝑂𝐸𝐸 �𝒔𝒔 𝑡𝑡 �𝒔𝒔 𝑡𝑡+1 �
𝒔𝒔 𝑡𝑡+2 �𝒔𝒔 𝑡𝑡+3 �𝒔𝒔 𝑡𝑡+𝐾𝐾− 𝑀𝑀𝐸𝐸𝑀𝑀𝑂𝑂𝑂𝑂𝑀𝑀𝐴𝐴𝑀𝑀𝐸𝐸𝑂𝑂𝐸𝐸𝐸𝐸𝐸𝐸𝑂𝑂𝐸𝐸 �𝒔𝒔 𝑡𝑡 �𝒔𝒔 𝑡𝑡+1 �𝒔𝒔 𝑡𝑡+2 �𝒔𝒔 𝑡𝑡+3 �𝒔𝒔 𝑡𝑡+𝐾𝐾− 𝒂𝒂 𝑡𝑡 : 𝑡𝑡+𝐾𝐾−
Original Observation Seq.
Action Seq.
Postion Emb.
𝑃𝑃𝐸𝐸𝑂𝑂𝐸𝐸𝑂𝑂𝐸𝐸𝑀𝑀𝑂𝑂𝑃𝑃𝑂𝑂 𝐿𝐿𝑀𝑀𝑀𝑀𝑂𝑂𝑂𝑂𝑀𝑀 𝐷𝐷𝑂𝑂𝐸𝐸𝐸𝐸𝐸𝐸𝑂𝑂𝐸𝐸 𝑂𝑂𝑂𝑂𝑂𝑂𝑂𝑂𝑂𝑂𝑂𝑂 𝑃𝑃𝐸𝐸𝐸𝐸𝑃𝑃 .
𝐻𝐻𝑂𝑂𝑀𝑀𝐸𝐸 �𝒚𝒚 𝑡𝑡+1 �𝒚𝒚 𝑡𝑡+2 �𝒚𝒚 𝑡𝑡+3 �𝒚𝒚 𝑡𝑡+𝐾𝐾−1 �𝒚𝒚 𝑡𝑡 𝑪𝑪𝒐𝒐𝒔𝒔𝑪𝑪𝑪𝑪𝑪𝑪𝑺𝑺𝑪𝑪𝑺𝑺𝑪𝑪𝑺𝑺𝒂𝒂𝑺𝑺𝑪𝑪𝑺𝑺𝒚𝒚
MovingAverage �𝒔𝒔 𝑡𝑡 �𝒔𝒔 𝑡𝑡+1 �𝒔𝒔 𝑡𝑡+2 �𝒔𝒔 𝑡𝑡+3 �𝒔𝒔 𝑡𝑡+𝐾𝐾− 𝒑𝒑
Momentum 𝑃𝑃𝐸𝐸𝐸𝐸𝑃𝑃 .
𝐻𝐻𝑂𝑂𝑀𝑀𝐸𝐸 𝑂𝑂𝑂𝑂𝑂𝑂𝑂𝑂𝑂𝑂𝑂𝑂 𝑃𝑃𝐸𝐸𝑂𝑂𝐸𝐸 .
𝐻𝐻𝑂𝑂𝑀𝑀𝐸𝐸 �𝒚𝒚 𝑡𝑡+1 �𝒚𝒚 𝑡𝑡+2 �𝒚𝒚 𝑡𝑡+3 �𝒚𝒚 𝑡𝑡+𝐾𝐾−1 �𝒚𝒚 𝑡𝑡
Stop 𝐺𝐺𝐸𝐸𝑀𝑀𝐸𝐸𝑂𝑂𝑂𝑂𝑂𝑂𝑀𝑀 𝐴𝐴𝐴𝐴𝐴𝐴 ( � )
Masked Observation Seq.
MovingAverage 𝑡 : 𝑡+𝐾− 𝒐𝒐 𝑡𝑡+3 𝒐𝒐 𝑡𝑡+ 𝒐𝒐 𝑡𝑡+ 𝒐𝒐 𝑡𝑡 ℎ 𝑤𝑤 𝑘𝑘 𝑊𝑊 𝐻𝐻 𝐾𝐾
(i) Masking.
Given an observation sequence of K timesteps τ o K = { o t , o t +1 , · · · , o t + K − 1 } and each observation containing n RGB frames, all the observations in the sequence are stacked to be a cuboid with the shape of K × H × W where H × W is the spatial size.
Note that the actual shape is K × H × W × D where
D = 3 n is the number of channels in each observation.
We omit the channel dimension for simplicity.
As illustrated in Figure 2, we divide the cuboid into regular non-overlapping cubes with the shape of k × h × w .
We then randomly mask a portion of the cubes following a uniform distribution and obtain a masked observation sequence ˜ τ
oK =
{ ˜ o t , ˜ o t +1 , · · · , ˜ o t + K − 1 } .
Following [63], we perform stochastic image augmentation Aug ( · ) ( e .
g ., random crop and intensity) on each masked observation in ˜ τ oK .
The objective of MLR is to predict the state representations of the unmasked observation sequence from the masked one in the latent space.
[Equation]
(ii) Encoding.
We adopt two encoders to learn state representations from masked observations and original observations respectively.
A CNN-based encoder f is used to encode each masked observation ˜ o
t
+ i into its corresponding latent state ˜s t
+ i ∈ R d .
After the encoding, we obtain a sequence of the masked latent states ˜ τ
sK =
{ ˜s t , ˜s t +1 , · · · , ˜s t + K − 1 } for masked observations.
The parameters of this encoder are updated based on gradient back-propagation in an end-to-end way.
We thus call it “online” encoder.
The state representations inferred from original observations are taken as the targets of subsequently described reconstruction.
To make them more robust, inspired by [32, 46, 63], we exploit another encoder for the encoding of original observations.
This encoder, called “momentum” encoder as in Figure 1, has the same architecture as the online encoder, and its parameters are updated by an exponential moving average (EMA) of the online encoder weights θ f with the momentum coefficient m ∈ [0 , 1) , as formulated below:
[Equation]
(iii) Decoding.
Similar to the mask-based modeling in the CV field, e .
g ., [25, 58], the online encoder in our MLR predicts the information of the masked contents from the unmasked contents.
As opposed to pixel-space reconstruction in [25, 58], MLR performs the reconstruction in the latent space to better perform RL policy learning.
Moreover, pixels usually have high information densities [25] which may contain distractions and redundancies for the policy learning in RL.
Considering the fact that in RL the next state is determined by the current state as well as the action, we propose to utilize both the actions and states as the inputs for prediction to reduce the possible ambiguity to enable an RL-tailored mask-based modeling design.
To this end, we adopt a transformer-based latent decoder to infer the reconstruction results via a global message passing where the actions and temporal information are exploited.
Through this process, the predicted information is “passed” to its corresponding state representations.
𝒂𝒂 𝑡𝑡 𝒂𝒂 𝑡𝑡+1 𝒂𝒂 𝑡𝑡+2 𝒂𝒂 𝑡𝑡+3 𝒂𝒂 𝑡𝑡+𝐾𝐾− 𝒂𝒂 𝑡𝑡 𝒂𝒂 𝑡𝑡+ 𝒂𝒂 𝑡𝑡+ 𝒂𝒂 𝑡𝑡+ 𝒂𝒂 𝑡𝑡+𝐾𝐾−1 �𝒔𝒔 𝑡𝑡 �
𝒔𝒔 𝑡𝑡+ �𝒔𝒔 𝑡𝑡+ �𝒔𝒔 𝑡𝑡+ �
𝒔𝒔 𝑡𝑡+𝐾𝐾−
ActionTokens 𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇 𝐸𝐸𝑇𝑇𝐸𝐸𝑇𝑇𝐸𝐸𝑇𝑇𝑇𝑇
PostionEmb.
𝒑𝒑 �𝒔𝒔 𝑡𝑡 �𝒔𝒔 𝑡𝑡+1 �𝒔𝒔 𝑡𝑡+2 �𝒔𝒔 𝑡𝑡+3 �𝒔𝒔 𝑡𝑡+𝐾𝐾−1 𝒂𝒂 𝑡𝑡 : 𝑡𝑡+𝐾𝐾−1 ActionSeq.
𝐸𝐸𝑇𝑇𝐸𝐸 ( � )
StateTokens �𝒔𝒔 𝑡𝑡 �𝒔𝒔 𝑡𝑡+ �𝒔𝒔 𝑡𝑡+ �𝒔𝒔 𝑡𝑡+ �
𝒔𝒔 𝑡𝑡+𝐾𝐾−
As shown in Figure 3, the input tokens of the latent decoder consist of both the masked state sequence ˜ τ
sK ( i .
e ., state tokens) and the corresponding action sequence τ aK = { a t , a t +1 , · · · , a t + K − 1 } ( i .
e ., action tokens).
Each action token is embedded as a feature vector with the same dimension as the stated token using an embedding layer, through an embedding layer Emb ( · ) .
Following the common practices in transformer-based models [55], we adopt the relative positional embeddings to encode relative temporal positional information into both state and action tokens with an elementwise addition denoted by " + " in the following equation (see Appendix B.1 for more details).
Notably, the state and action token at the same timestep t
+ i share the same positional embedding p t + i ∈ R d .
Thus, the inputs of latent decoder can be mathematically represented as follows:
[Equation]
The input token sequence is fed into a Transformer encoder [55] consisting of L attention layers.
Each layer is composed of a Multi-Headed Self-Attention (MSA) layer [55], a layer normalisation (LN) [3], and multilayer perceptron (MLP) blocks.
The process can be described as follows:
[Equation]
The output tokens of the latent decoder, i .
e ., ˆ τ sK = { ˆs t , ˆs t +1 , · · · , ˆs t + K − 1 } , are the predictive reconstruction results for the latent representations inferred from the original observations.
We elaborate on the reconstruction loss between the prediction results and the corresponding targets in the following.
(iv) Reconstruction.
Motivated by the success of BYOL [15] in self-supervised learning, we use an asymmetric architecture for calculating the distance between the predicted/reconstructed latent states
and
the target states, similar to [46, 63].
For the outputs of the latent decoder, we use a projection
head g and a prediction head q to get the final prediction result ˆy t
+ i =
q
( g ( ˆs t + i ))
corresponding to s t
+ i .
For the encoded results of original observations, we use a momentum-updated projection head ¯ g whose weights are updated with an EMA of the weights of the online projection head.
These two projection heads have the same architectures.
The outputs of the momentum projection head ¯ g , i .
e .,
¯y t
+ i = ¯ g ( ¯s t + i ) , are the final reconstruction targets.
Here, we apply a stop-gradient operation as illustrated in Figure 1 to avoid model collapse, following [15].
The objective of MLR is to enforce the final prediction result ˆy t
+ i to be as close as possible to its corresponding target ¯y t
+ i .
To achieve this, we design the reconstruction loss in our proposed MLR by calculating the cosine similarity between ˆy t
+ i and ¯y t
+ i , which can be formulated below:
[Equation]
The loss L mlr is used to update the parameters of the online networks, including encoder f , predictive latent decoder ϕ , projection head g and prediction head q .
Through our proposed self-supervised auxiliary objective MLR, the learned state representations by the encoder will be more informative and thus can further facilitate policy learning.
Objective.
The proposed MLR serves as an auxiliary task, which is optimized together with the policy learning.
Thus, the overall loss function L total for RL agent training is:
[Equation]
) where L rl and L mlr are the loss functions of the base RL agent ( e .
g ., SAC [18] and Rainbow [26]) and the proposed mask-based latent reconstruction, respectively.
λ is a hyperparameter for balancing the two terms.
Notably, the agent of vision-based RL commonly consists of two parts, i .
e
., the (state) representation network ( i .
e ., encoder) and the policy learning network.
The encoder of MLR is taken as the representation network to encode observations into the state representations for RL training.
The latent decoder can be discarded during testing since it is only needed for the optimization with our proposed auxiliary objective during training.
More details can be found in Appendix B.
Experiment 4.1 Setup
Environments and Evaluation.
We evaluate the sample efficiency of our MLR on both the continuous control benchmark DeepMind Control Suite (DMControl) [52] and the discrete control benchmark Atari [5].
On DMControl, following the previous works [32, 60, 31, 63], we choose six commonly used environments from DMControl, i .
e ., Finger, spin ; Cartpole, swingup ; Reacher, easy ;
Cheetah, run ; Walker, walk and Ball in cup, catch for the evaluation.
We test the performance of
RL agents with the mean and median scores over 10 episodes at 100k and 500k environment steps, referred to as DMControl-100k and DMControl-500k benchmarks, respectively.
The score of each environment ranges from 0 to 1000 [52].
For discrete control, we test agents on the Atari-100k benchmark [67, 54, 29, 32] which contains 26 Atari games and allows the agents 100k interaction steps ( i .
e ., 400k environment steps with action repeat of 4) for training.
Human-normalized score (HNS) 3 is used to measure the performance on each game.
Considering the high variance of the scores on this benchmark, we test each run over 100 episodes [46].
To achieve a more rigorous evaluation on high-variance benchmarks such as Atari-100k with a few runs, recent work Rliable [1] systematically studies the evaluation bias issue in deep RL and recommends robust and efficient aggregate metrics to evaluate the overall performance (across all tasks and runs), e .
g ., interquartilemean (IQM) and optimality gap (OG) 4 , with percentile confidence intervals (CIs, estimated by the percentile bootstrap with stratified sampling).
We follow aforementioned common practices and report the aggregate metrics on the Atari-100k benchmark with 95% CIs.
Our method augments Baseline with the proposed MLR objective (denoted as MLR )
[Table]
Implementation.
SAC [18] and Rainbow [26] are taken as the base continuous-control agent and discrete-control agent, respectively (see Appendix A.1 and A.2 for the details of the two algorithms).
In our experiments, we denote the base agents trained only by RL loss L rl (as in Equation 6) as
Baseline , while denoting the models of applying our proposed MLR to the base agents as MLR for the brevity.
Note that compared to naive SAC or Rainbow, our Baseline additionally adopts data augmentation (random crop and random intensity).
We adopt this following the prior works [31, 60] which uncovers that applying proper data augmentation can significantly improve the sample efficiency of SAC or Rainbow.
As shown in Equation 6, we set a weight λ to balance L rl and L mlr so that the gradients of these two loss items lie in a similar range and empirically find λ = 1 works well in most environments.
In MLR, by default, we set the length of a sampled trajectory K toand mask ratio η to 50%.
We set the size of the masked cube ( k × h × w ) to 8 × 10 × 10 on most
DMControl tasks and 8 × 12 × 12 on the Atari games.
More implementation details can be found in
Appendix B.
4.2 Comparison with State-of-the-Arts
DMControl.
We compare our proposed MLR with the state-of-the-art (SOTA) sample-efficient
RL methods proposed for continuous control, including PlaNet [19], Dreamer [20], SAC+AE [61],
SLAC [33], CURL [32], DrQ [60] and PlayVirtual [63].
The comparison results are shown in Table 1, and all results are averaged over 10 runs with different random seeds.
We can observe that: (i)
MLR significantly improves Baseline in both DMControl-100k and DMControl-500k, and achieves consistent gains relative to Baseline across all environments.
It is worthy to mention that, for the
DMControl-100k, our proposed method outperforms Baseline by 25.3% and 34.7% in mean and median scores, respectively.
This demonstrates the superiority of MLR in improving the sample efficiency of RL algorithms.
(ii) The RL agent equipped with MLR outperforms most state-of-the-art methods on DMControl-100k and DMControl-500k.
Specifically, our method surpasses the best previous method ( i .
e ., PlayVirtual) by 43.5 and 35.5 respectively on mean and median scores on
DMControl-100k.
Our method also delivers the best median score and reaches a comparable mean score with the strongest SOTA method on DMControl-500k.
Atari-100k.
We further compare MLR with the SOTA model-free methods for discrete control, including DER [54], OTR [29], CURL [32], DrQ [60], DrQ( ϵ ) (DrQ using the ϵ -greedy parameters in [9]) , SPR [46] and PlayVirtual [63].
These methods and our MLR for Atari are all based on Rainbow [26].
The Atari-100k results are shown in Figure 4.
MLR achieves an interquartile-mean (IQM) score of 0.432, which is 28.2% higher than SPR (IQM: 0.337) and 15.5% higher than PlayVirtual (IQM: 0.374).
This indicates that MLR has the highest sample efficiency overall.
For the optimality gap (OG) metric, MLR reaches an OG of 0.522 which is better than SPR (OG: 0.577) and PlayVirtual (OG: 0.558), showing that our method performs closer to the desired target, i .
e ., human-level performance.
The full scores of MLR (over 3 random seeds) across the 26 Atari games and more comparisons and analysis can be found in Appendix C.1.
[Figure] [Figure]
4.3 Ablation Study
In this section, we investigate the effectiveness of our MLR auxiliary objective, the impact of masking strategies and the model/method design.
Unless otherwise specified, we conduct the ablation studies on the DMControl-100k benchmark and run each model with 5 random seeds.
Effectiveness evaluation.
Besides the comparison with SOTA methods, we demonstrate the effectiveness of our proposed MLR by studying its improvements compared to our Baseline.
The numerical results are presented in Table 1, while the curves of test performance during the training process are given in Appendix C.2.
Both numerical results and test performance curves can demonstrate that our method obviously outperforms Baseline across different environments thanks to more informative representations learned by MLR.
Masking strategy.
We compare three design choices of the masking operation: (i) Spatial masking (denoted as MLR-S ): we randomly mask patches for each frame independently.
(ii) Temporal masking (denoted as MLR-T ): we divide the input observation sequence into multiple segments along the temporal dimension and mask out a portion of segments randomly.
(Here, the segment length is set to be equal to the temporal length of cube, i .
e ., k .)
(iii) Spatial-temporal masking (also referred to as “cube masking”): as aforementioned and illustrated in Figure 2, we rasterize the observation sequence into non-overlapping cubes and randomly mask a portion of them.
Except for the differences described above, other configurations for masking remain the same as our proposed spatial-temporal ( i .
e ., cube) masking.
From the results in Table 2, we have the following observations: (i) All three masking strategies ( i .
e ., MLR-S , MLR-T and MLR ) achieve mean score improvements compared to Baseline by 18.5% , 12.2% and 25.0% , respectively, and achieve median score improvements by 23.4% , 25.0% and 35.9% , respectively.
This demonstrates the effectiveness of the core idea of introducing mask-based reconstruction to improve the representation learning of RL.
(ii)
Spatialtemporal masking is the most effective strategy over these three design choices.
This strategy matches better with the nature of video data due to its spatial-temporal continuity in masking.
It encourages the state representations to be more predictive and consistent along the spatial and temporal dimensions, thus facilitating policy learning in RL.
Reconstruction target.
In masked language/image modeling, reconstruction/prediction is commonly performed in the original signal space, such as word embeddings or pixels.
To study the influence of the reconstruction targets for the task of RL, we compare two different reconstruction spaces: (i) Pixel space reconstruction (denoted as MLR-Pixel ): we predict the masked contents directly by reconstructing original pixels, like the practices in CV and NLP domains; (ii) Latent space reconstruction ( i .
e .,
MLR ): we reconstruct the state representations ( i .
e ., features) of original observations from masked observations, as we proposed in MLR.
Table 2 shows the comparison results.
The reconstruction in the latent space is superior to that in the pixel space in improving sample efficiency.
As discussed in the preceding sections, vision data might contain distractions and redundancies for policy learning, making the pixel-level reconstruction unnecessary.
Besides, latent space reconstruction is more conducive to the coordination between the representation learning and the policy learning in RL, because the state representations are directly optimized.
[Table]
[Figure]
   
 
          
      
         0HDQ 0HGLDQ
Mask ratio.
In recent works of masked image modeling [25, 58], the mask ratio is found to be crucial for the final performance.
We study the influences of different masking ratios on sample efficiency in Figure 5 (with 3 random seeds) and find that the ratio of 50% is an appropriate choice for our proposed MLR.
An over-small value of this ratio could not eliminate redundancy, making the objective easy to be reached by extrapolation from neighboring contents that are free of capturing and understanding semantics from visual signals.
An over-large value leaves few contexts for achieving the reconstruction goal.
As discussed in [25, 58], the choice of this ratio varies for different modalities and depends on the information density of the input signals.
Action token.
We study the contributions of action tokens used for the latent decoder in Figure 1 by discarding it from our proposed framework.
The results are given in Table 3.
Intuitively, prediction only from visual signals is of more or less ambiguity.
Exploiting action tokens benefits by reducing such ambiguity so that the gradients of less uncertainty can be obtained for updating the encoder
[Table]
[Table]
Masking features. We compare “masking pixels” and “masking features” in Table 3.
Masking features (denoted by MLR-F ) does not perform equally well compared with masking pixels as proposed in MLR, but it still achieves significant improvements relative to Baseline .
Why not use a latent decoder for targets?
We have tried to add a momentum-updated latent decoder for obtaining the target states ¯s t
+ i as illustrated in Figure 1.
The results in Table 3 show that adding a momentum decoder leads to performance drops.
Since there is no information prediction for the state representation learning from the original observation sequence without masking, we do not need to refine the implicitly predicted information like that in the outputs ˆs t
+ i of the online encoder.
depth.
We the
[Table]
Decoder depth.
We analyze the influence of using Transformer-based latent decoders with different depths.
We show the experimental results in Table 4.
Generally, deeper latent decoders lead to worse sample efficiency with lower mean and median scores.
Similar to the designs in [25, 58], it is appropriate to use a lightweight decoder in MLR, because we expect the predicting masked information to be mainly completed by the encoder instead of the decoder.
Note that the state representations inferred by the encoder are adopted for the policy learning in RL.
Similarity loss.
We compare models using two kinds of similarity metrics to measure the distance in the latent space and observe that using cosine similarity loss is better than using mean squared error (MSE) loss.
The results and analysis can be found in Appendix C.2.
Projection and prediction heads.
Previous works [15, 46, 11] have shown that in self-supervised learning, supervising the feature representations in the projected space via the projection/prediction heads is often better than in the original feature space.
We investigate the effect of the two heads and find that both improve agent performance (see Appendix C.2).
Sequence length and cube size.
These two factors can be viewed as hyperparameters.
Their corresponding experimental analysis and results are in Appendix C.2.
4.4 More Analysis
We make more detailed investigation and analysis of our MLR from the following aspects with details shown in Appendix C.3.
(i)
We provide a more detailed analysis of the effect of each masking strategy.
(ii)
The quality of the learned representations are further evaluated through a pretraining evaluation and a regression accuracy test.
(iii)
We also investigate the performance of MLR on more challenging control tasks and find that MLR is still effective.
(iv) We additionally discuss the relationship between
PlayVirtual and MLR.
They both achieve leading performance in improving sample efficiency but from different perspectives.
(v) We discuss the applications and limitations of MLR.
We observe that
MLR is more effective on tasks with backgrounds and viewpoints that do not change drastically than on tasks with drastically changing backgrounds/viewpoints or vigorously moving objects.
Conclusion
In this work, we make the first effort to introduce the mask-based modeling to RL for facilitating policy learning by improving the learned state representations.
We propose MLR, a simple yet effective self-supervised auxiliary objective to reconstruct the masked information in the latent space.
In this way, the learned state representations are encouraged to include richer and more informative features.
Extensive experiments demonstrate the effectiveness of MLR and show that MLR achieves the state-of-the-art performance on both DeepMind Control and Atari benchmarks.
We conduct a detailed ablation study for our proposed designs in MLR and analyze their differences from that in
NLP and CV domains.
We hope our proposed method can further inspire research for vision-based
RL from the perspective of improving representation learning.
Moreover, the concept of masked latent reconstruction is also worthy of being explored and extended in CV and NLP fields.
We are looking forward to seeing more mutual promotion between different research fields.
Acknowledgments
We thank all the anonymous reviewers for their valuable comments on our paper.
A Extended Background A.1 Soft Actor-Critic
Soft Actor-Critic (SAC) [18] is an off-policy actor-critic algorithm, which is based on the maximum entropy RL framework where the standard return maximization objective is augmented with an entropy maximization term [66].
SAC has a soft Q-function Q and a policy π .
The soft Q-function is learned by minimizing the soft Bellman error:
[Equation]
where tr = ( s t , a t , r t , s t +1 ) is a tuple with current state s t , action a t , successor s t +1 and reward r t ,
D is the replay buffer and ¯ V is the target value function.
¯ V has the following expectation:
[Equation]
where ¯ Q is the target Q-function whose parameters are updated by an exponential moving average of the parameters of the Q-function Q , and the temperature α is used to balance the return maximization and the entropy maximization.
The policy π is represented by using the reparameterization trick and optimized by minimizing the following objective:
[Equation]
where ϵ t is the input noise vector sampled from Gaussian distribution N (0 , I ) , and f π ( ϵ t ; s t ) denotes actions sampled stochastically from the policy π , i .
e ., f π ( ϵ t ; s t ) ∼ tanh( µ π
[Equation]
s t )
+ σ π ( s t ) ⊙ ϵ t ) .
SAC is shown to have a remarkable performance in continuous control [18].
A.2 Deep Q-network and Rainbow
Deep Q-network (DQN) [39] trains a neural network Q θ with parameters θ to approximate the
Q-function.
DQN introduces a target Q-network Q θ ′ for stable training.
The target Q-network Q θ ′ has the same architecture as the Q-network Q θ , and the parameters θ ′ are updated with θ every certain number of iterations.
The objective of DQN is to minimize the squared error between the predictions of Q θ and the target values provided by Q θ ′ :
[Equation]
Rainbow [26] integrates a number of improvements on the basis of the vanilla DQN [39] including: (i) employing modified target Q-value sampling in Double DQN [53]; (ii) adopting Prioritized
Experience Replay [44] strategy; (iii) decoupling the value function of state and the advantage function of action from Q-function like Dueling DQN [56]; (iv) introducing distributional RL and predicting value distribution as C51 [6]; (v) adding parametric noise into the network parameters like NoisyNet [14]; and (vi) using multi-step return [50].
Rainbow is typically regarded as a strong model-free baseline for discrete control.
A.3 BYOL-style Auxiliary Objective
BYOL [15] is a strong self-supervised representation learning method by enforcing the similarity of the representations of the same image across diverse data augmentation.
The pipeline is shown in Figure 6.
BYOL has an online branch and a momentum branch.
The momentum branch is used for computing a stable target for learning representations [24, 51].
BYOL is composed of an online encoder f , a momentum encoder ¯ f , an online projection head g , a momentum projection head ¯ g and an prediction head q .
The momentum encoder and projection head have the same architectures as the corresponding online networks and are updated by an exponential moving average (EMA) of the online weights (see Equation 1 in the main manuscript).
The prediction head is only used in the online branch, making BYOL’s architecture asymmetric.
Given an image x , BYOL first produces two views v and v ′ from x through images augmentations.
The online branch outputs a representation y =
f ( v ) and a projection z = g ( y ) , and the momentum branch outputs y ′
=
¯ f ( v ′ ) and a target projection z ′ =
¯ g ( y ′ ) .
BYOL then use a prediction head q to regress z ′ from z , i .
e ., q ( z ) → z ′ .
BYOL minimizes the similarity loss between q ( z ) and a stop-gradient 5 target sg ( z ′ ) .
[Equation]
[Figure]
Inspired by the success of BYOL in learning visual representations, recent works introduce BYOLstyle learning objectives to vision-based RL for learning effective state representations and show promising performance [46, 63, 59, 22, 17].
The BYOL-style learning is often integrated into auxiliary objectives in RL such as future state prediction [46, 17], cycle-consistent dynamics prediction [63], prototypical representation learning [59] and invariant representation learning [22].
These works also show that it is more effective to supervise/regularize the predicted representations in the BYOL’s projected latent space than in the representation or pixel space.
Besides, the BYOL-style auxiliary objectives are commonly trained with data augmentation since it can conveniently produce two BYOL views.
For example, SPR [46] and PlayVirtual [63] apply random crop and random intensity to input observations in Atari games.
The proposed MLR auxiliary objective can be categorized into
BYOL-style auxiliary objectives.
B Implementation Detail B.1 Network Architecture
Our model has two parts: the basic networks and the auxiliary networks.
The basic networks are composed of a representation network ( i .
e ., encoder)
f parameterized by θ f and the policy learning networks ω ( e . g ., SAC [18] or Rainbow [26]) parameterized by θ ω .
We follow CURL [32] to build the architecture of the basic networks on the DMControl [52] benchmarks.
The encoder is composed of four convolutional layers (with a rectified linear units (ReLU) activation after each), a fully connected (FC) layer, and a layer normalization (LN) [3] layer.
Furthermore, the policy learning networks are built by multilayer perceptrons (MLPs).
For the basic networks on Atari [5], we also follow CURL to adopt the original architecture of Rainbow [26] where the encoder consists of three convolutional layers (with a ReLU activation after each), and the
Q-learning heads are MLPs.
Our auxiliary networks have online networks and momentum (or target) networks.
The online networks consist of an encoder f , a predictive latent decoder (PLD) ϕ , a projection head g and a prediction head q , parameterized by θ f , θ ϕ , θ g and θ q , respectively.
Notably, the encoders in the basic networks and the auxiliary networks are shared .
As shown in Figure 1 in our main manuscript, there are a momentum encoder ¯ f and a momentum projection head ¯ g for computing the self-supervised targets.
The momentum networks have the same architectures as the corresponding online networks.
Our PLD is a transformer encoder [55] and has two standard attention layers (with a single attention head).
We use an FC layer as the action embedding head to transform the original action into an embedding which has the same dimension as the state representation ( i .
e ., state token).
The transformer encoder treats each input token as independent of the other.
Thus, positional embeddings, which encode the positional information of tokens in a sequence, are added to the input tokens of
PLD to maintain their relative temporal positional information ( i .
e ., the order of the state/action sequences).
We use sine and cosine functions to build the positional embeddings following [55]:
[Equation]
Require: An online encoder f , a momentum encoder ¯ f , a predictive latent decoder ϕ , an online projection head g , a momentum projection head ¯ g , a prediction head q and policy learning networks ω , parameterized by θ f , ¯ θ f , θ ϕ , θ g , ¯ θ g , θ q and θ ω , respectively; a stochastic cube masking function Mask ( · ) ; a stochastic image augmentation function Aug ( · ) ; an optimizer
Optimize ( · , · ) .
environment
Randomly
Perform augmentation and encoding: { ˜s t , ˜s t +1 , · · · , ˜s t + K − 1 } ← { f ( Aug ( ˜o t )) , f
( Aug ( ˜o t +1 )) , · · · , f ( Aug ( ˜o t + K − 1 ) } 12:
Perform decoding: { ˆs t , ˆs t +1 , · · · , ˆs t + K − 1 } ← ϕ ( { ˜s t , ˜s t +1 , · · · , ˜s t + K − 1 } ; { a t , a t +1 , · · · , a t + K − 1 } ) 13:
Perform projection and prediction: { ˆy t , ˆy t +1 , · · · , ˆy t + K − 1 } ← { q ( g ( ˆs t )) , q ( g ( ˆs t +1 )) , · · · , q ( g ( ˆs t + K − 1 )) } 14:
Calculate targets: { ¯y t , ¯y t +1 , · · · , ¯y t + K − 1 } ← { ¯ g ( ¯ f ( Aug ( o t ))) , ¯ g ( ¯ f ( Aug ( o t +1 ))) , · · · , ¯ g ( ¯ f ( Aug ( o t + K − 1 ))) } 15:
Calculate MLR loss: L mlr ← 1 − 1 K (cid:80) K − 1 i = ˆy t + i ∥ ˆy t + i ∥ 2 ¯y t + i ∥ ¯y t
+ i ∥16:
Calculate RL loss L rl based on a given base RL algorithm ( e . g ., SAC) 17:
Calculate total loss: L total ← L rl + λ L mlr 18:
Update online parameters: ( θ f , θ ϕ , θ g , θ q , θ ω ) ← Optimize (( θ f , θ ϕ , θ g , θ q , θ ω ) , L total ) 19:
Update momentum parameters: (¯ θ f , ¯ θ g ) ← m (¯ θ f , ¯ θ g )
+ (1 − m )( θ f , θ g ) 20: end while where pos is the position, j is the dimension and d is the embedding size (equal to the state representation size).
We follow PlayVirtual [63] in the architecture design of the projection and the prediction heads, built by MLPs and FC layers.
B.2 Training Detail
Optimization and training.
The training algorithm of our method is presented in Algorithm 1.
We use Adam optimizer [30] to optimize all trainable parameters in our model, with ( β 1 , β 2 ) =
(0 . 9 , 0 . 999) (except for (0 . 5 , 0 . 999) for SAC temperature α ).
Modest data augmentation such as crop/shift is shown to be effective for improving RL agent performance in vision-based RL [60, 31, 46, 63].
Following [63, 46, 32], we use random crop and random intensity in training the auxiliary objective, i .
e ., L mlr .
Besides, we warmup the learning rate of our MLR objective on
DMControl by
[Equation]
where the lr and lr 0 denote the current learning rate and the initial learning rate, respectively, and step _ num and warmup _ step denote the current step and the warmup step, respectively.
We empirically find that the warmup schedule bring improvements on DMControl.
Hyperparameters.
We present all hyperparameters used for the DMControl benchmarks [52] in
Table 12 and the Atari-100k benchmark in Table 13.
We follow prior work [63, 46, 32] for the policy learning hyperparameters ( i .
e ., SAC and Rainbow hyperparameters).
The hyperparameters specific to our MLR auxiliary objective, including MLR loss weight λ , mask ratio η , the length of the sampled sequence K , cube shape k × h × w and the depth of the decoder L , are shown in the bottom of the tables.
By default, we set λ to 1, η to 50 % , L to 2, k to 8, and h × w to 10 × 10 on DMControl and 12 × 12 on Atari.
We exceptionally set k to 4 in Cartpole-swingup and Reacher-easy on DMControl due to their large motion range, and λ to 5 in Pong and Up N Down on Atari as their MLR losses are relatively smaller than the rest 24 Atari games.
Baseline and data augmentation.
Our baseline models ( Baseline ) are equivalent to CURL [32] without the auxiliary loss except for the slight differences on the applied data augmentation strategies.
CURL adopts random crop for data augmentation.
We follow the prior work SPR [46] and PlayVirtual [63] to adopt random crop and random intensity for both our Baseline and MLR.
GPU and wall-clock time.
In our experiment, we run MLR with a single GPU ( NVIDIA Tesla
V100 or GeForce RTX 3090) for each environment.
MLR has the same inference time complexity as Baseline since both use only the encoder and policy learning head during testing.
On Atari, the average wall-clock training time is 6.0, 10.9, 4.0, and 8.2 hours for SPR, PlayVirtual, Baseline and
MLR, respectively.
On DMControl, the training time is 4.3, 5.2, 3.8, 6.5 hours for SPR, PlayVirtual,
Baseline and MLR, respectively.
We will leave the optimization of our training strategy as future work to speed up the training, e . g ., reducing the frequency of using masked-latent reconstruction.
The evaluation is based on a single GeForce RTX 3090 GPU.
B.3 Environment and Code
DMControl [52] and Atari [5] are widely used environment suites in RL community, which are public and do not involve personally identifiable information or offensive contents.
We use the two environment suites to evaluate model performance.
The implementation of MLR is based on the open-source PlayVirtual [63] codebase 6 .
The statistical tools on Atari are obtained from the open-source library rliable 7 [1].
C More Experimental Results and Analysis C.1 More Atari-100k Results
We present the comparison results across all 26 games on the Atari-100k benchmark in Table 5.
Our
MLR reaches the highest scores on 11 out of 26 games and outperforms the compared methods on the aggregate metrics, i .
e ., interquartile-mean (IQM) and optimality gap (OG) with 95% confidence intervals (CIs).
Notably, MLR improve the Baseline performance by 47.9% on IQM, which shows the effectiveness of our proposed auxiliary objective.
We also present the performance profiles 8 using human-normalized scores (HNS) with 95% CIs in Figure 7.
The performance profiles confirm the superiority and effectiveness of our MLR.
The results of DER [54], OTR [29], CURL [32], DrQ [60] and SPR [46] are from rliable [1], based on 100 random seeds.
The results of PlayVirtual [63] are based on 15 random seeds, and the results of Baseline and MLR are averaged over 3 random seeds and each run is evaluated with 100 episodes.
We report the standard deviations across runs of
Baseline and MLR in Table 6.
C.2 Extended Ablation Study
We give more details of the ablation study.
Again, unless otherwise specified, we conduct the ablations on DMControl-100k with 5 random seeds.
Effectiveness evaluation.
Besides the numerical results in Table 1 in the main manuscript, we present the test score curves during the training process in Figure 8.
Each curve is drawn based on 10 random seeds.
The curves demonstrate the effectiveness of the proposed MLR objective.
Besides, we observe that MLR achieves more significant gains on the relatively challenging tasks ( e .
g .,
Walker-walk
and
Cheetah-run with six control dimensions) than on the easy tasks ( e .
g ., Cartpole-swingup with a single control dimension).
This is because solving challenging tasks often needs more effective representation learning, leaving more room for MLR to play its role.
[Table]
( τ )
[Figure]
Similarity loss.
MLR performs the prediction in the latent space where the value range of the features is unbounded.
Using cosine similarity enables the optimization to be conducted in a normalized space, which is more robust to outliers.
We compare MLR models using mean squared error (MSE) loss and cosine similarity loss in Table 7.
We find that using MSE loss is worse than using cosine similarity loss.
Similar observations are found in SPR [46] and BYOL [15].
Projection and prediction heads.
MLR adopt the projection and prediction heads following the widely used design in prior works [15, 46].
We study the impact of the heads in Table 7.
The results show that using both projection and prediction heads performs best, which is consistent with the observations in the aforementioned prior works.
[Table]
   (QYVWHSV[H       ( S L V RGH  V F R U H )LQJHUVSLQ    (QYVWHSV[H      ( S L V RGH  V F R U H &DUWSROHVZLQJXS    (QYVWHSV[H       ( S L V RGH  V F R U H 5HDFKHUHDV\    (QYVWHSV[H     ( S L V RGH  VF R U H &KHHWDKUXQ    (QYVWHSV[H       ( S L V RGH  VF R U H
:DONHUZDON    (QYVWHSV[H       ( S L V RGH  VF R U H %DOOLQFXSFDWFK 2XUV %DVHOLQH
In most environments on DMControl, our results (blue
) are consistently better than
Sequence length.
Table 8 shows the results of the observation sequence length K at {8, 16, 24}.
A large K ( e .
g ., 24) does not bring further performance improvement as the network can reconstruct the missing content in a trivial way like copying and pasting the missing content from other states.
In contrast, a small K like 8 may not be sufficient for learning rich context information.
A sequence length of 16 is a good trade-off in our experiment.
Cube size.
Our space-time cube can be flexibly designed.
We investigate the influence of temporal depth k and the spatial size ( h and w , h = w by default).
The results based on 3 random seeds are shown in Figure 9.
In general, a proper cube size leads to good results.
The spatial size has a large influence on the final performance.
A moderate spatial size ( e . g ., 10 × 10 ) is good for MLR .
The performance generally has an upward tendency when increasing the cube depth k .
However, a cube mask with too large k possibly masks some necessary contents for the reconstruction and hinders the training.
[Table]
[Table]
C.3 Discussion
More analysis on MLR-S, MLR-T and MLR.
MLR-S masks spatial patches for each frame independently while MLR-T performs masking of entire frames.
MLR-S and MLR-T enable a model to capture rich spatial and temporal contexts, respectively.
We find that some tasks ( e
[Table]
g ., Fingerspin and Walker-walk ) have more complicated spatial contents than other tasks on the DMControl benchmarks, requiring stronger spatial modeling capacity.
Therefore, MLR-S performs better than
MLR-T on these tasks.
While for tasks like Cartpole-swingup and Ball-in-cup-catch , where objects have large motion dynamics, temporal contexts are more important, and MLR-T performs better.
MLR using space-time masking harnesses both advantages in most cases.
But it is slightly inferior to
MLR-S/-T in Finger-spin and Cartpole-swingup respectively, due to the sacrifice of full use of spatial or temporal context as in MLR-S or MLR-T . Evaluation on learned representations.
We evaluate the learned representations from two aspects: (i) Pretraining evaluation .
We conduct pretraining experiments to test the effectiveness of the learned representation.
Data collection : We use a 100k-steps pretrained Baseline model to collect 100k transitions.
MLR pretraining : We use the collected data to pretrain MLR without policy learning ( i .
e ., only with MLR objective).
Representation testing : We compare two models on DMControl-100k,
Baseline with the encoder initialized by the MLR-pretrained encoder (denoted as MLR-Pretraining )                  
  
     
  0HDQ
[Figure]
  
        
   
  

[Figure]
[Table]
[Table]
[Table]
and Baseline without pretraining ( i .
e ., Baseline ). The results in Table 9 show that MLR-Pretraining outperforms Baseline which is without pretraining but still underperforms MLR which jointly learns the RL objective and the MLR auxiliary objective (also denoted as MLR-Auxiliary ).
This validates the importance of the learned state representations more directly, but is not the best practice to take the natural of RL into account for getting the most out of MLR.
This is because that RL agents learn from interactions with environments, where the experienced states vary as the policy network is updated.
(ii) Regression accuracy test.
We compute the cosine similarities between the learned representations from the masked observations and those from the corresponding original observations ( i .
e ., observations without masking).
The results in Table 10 show that there are high cosine similarity scores of the two representations in MLR while low scores in Baseline .
This indicates that the learned representations of MLR are more predictive and informative. Performance on more challenging control tasks.
We further investigate the effectiveness of MLR on more challenging control tasks such as Reacher-hard and Walker-run .
We show the test scores based on 3 random seeds at 100k and 500k steps in Table 11. Our MLR still significantly outperforms
Baseline .
The relationship between PlayVirtual and our MLR.
The two works have a consistent purpose, i .
e ., improving RL sample efficiency, but address this from two different perspectives.
PlayVirtual focuses on how to generate more trajectories for enhancing representation learning.
In contrast, our
MLR focuses on how to exploit the data more efficiently by promoting the model to be predictive of the spatial and temporal context through masking for learning good representations.
They are compatible and have their own specialities, while our MLR outperforms PlayVirtual on average.
Application and limitation.
While we adopt the proposed MLR objective to two strong baseline algorithms ( i .
e ., SAC and Rainbow) in this work, MLR is a general approach for improving sample efficiency in vision-based RL and can be applied to most existing vision-based RL algorithms ( e .
g .,
EfficientZero 9 [62]).
We leave more applications of MLR in future work.
We have shown the effectiveness of the proposed MLR on multiple continuous and discrete benchmarks.
Nevertheless, there are still some limitations to MLR.
When we take a closer look at the performance of MLR and
Baseline on different kinds of Atari games, we find that MLR brings more significant performance improvement on games with backgrounds and viewpoints that do not change drastically (such as
Qbert and Frostbite ) than on games with drastically changing backgrounds/viewpoints or vigorously moving objects (such as Crazy Climber and Freeway ).
This may be because there are low correlations between adjacent regions in spatial and temporal dimensions on the games like Crazy Climber and
Freeway so that it is more difficult to exploit the spatial and temporal contexts by our proposed mask-based latent reconstruction.
Besides, MLR requires several hyperparameters (such as mask ratio and cube shape) that might need to be adjusted for particular applications.
[Table]
D Broader Impact
Although the presented mask-based latent reconstruction (MLR) should be categorized as research in the field of RL, the concept of reconstructing the masked content in the latent space may inspire new approaches and investigations in not only the RL domain but also the fields of computer vision and natural language processing.
MLR is simple yet effective and can be conveniently applied to real-world applications such as robotics and gaming AI.
However, specific uses may have positive or negative effects ( i .
e ., the dual-use problem).
We should follow the responsible AI policies and consider safety and ethical issues in the deployments.
[Table]
[Table]
MLR
[Table]
Hyperparameters
[Table]
[Table]