T IME -M YOPIC G O -E XPLORE : L EARNING A S TATE R EPRESENTATION FOR THE G O -E XPLORE P ARADIGM
Anonymous authors
Paper under double-blind review
A BSTRACT
Very large state spaces with a sparse reward signal are difficult to explore.
The lack of a sophisticated guidance results in a poor performance for numerous reinforcement learning algorithms.
In these cases, the commonly used random exploration is often not helpful.
The literature shows that this kind of environments require enormous efforts to systematically explore large chunks of the state space.
Learned state representations can help here to improve the search by providing semantic context and build a structure on top of the raw observations.
In this work we introduce a novel time-myopic state representation that clusters temporally close states together while providing a time prediction capability between them.
By adapting this model to the Go-Explore paradigm (Ecoffet et al., 2021b), we demonstrate the first learned state representation that reliably estimates novelty instead of using the hand-crafted representation heuristic.
Our method shows an improved solution for the detachment problem which still remains an issue at the Go-Explore Exploration
Phase.
We provide evidence that our proposed method covers the entire state space with respect to all possible time trajectories — without causing disadvantageous conflict-overlaps in the cell archive.
Analogous to native Go-Explore, our approach is evaluated on the hard exploration environments MontezumaRevenge
Gravitar and Frostbite (Atari) in order to validate its capabilities on difficult tasks.
Our experiments show that time-myopic Go-Explore is an effective alternative for the domain engineered heuristic while also being more general.
The source code of the method is available on GitHub made .public.after.acceptance
I NTRODUCTION
In recent years, the problem of sufficient and reliable exploration remains an area of research in the domain of reinforcement learning.
In this effort, an agent seeks to maximize its extrinsic discounted sum of rewards without ending up with a sub-optimal behavior policy.
A good exploration mechanism should encourage the agent to seek novelty and dismiss quick rewards for a healthy amount of time to evaluate long-term consequences of the action selection.
Four main issues are involved when performing an exploration in a given environment: (i) catastrophic forgetting (Goodfellow et al., 2013) as the data distribution shifts because the policy changes, (ii) a neural network’s overconfident evaluation of unseen states (Zhang et al., 2018), (iii) sparse reward
Markov Decision Processes and (iv) the exploration-exploitation trade-off (Sutton and Barto, 2018;
Ecoffet et al., 2021a).
The latter causes a significant problem: the greater the exploitation the less exploration is done.
Hereby, making novelty search less important when the agent can easily reach states with a large rewards.
To address these difficulties, Ecoffet et al.
(2021b) propose a new approach called Go-Explore and achieve state-of-the-art results on hard exploration problems.
However, Go-Explore relies on hand-crafted heuristics.
In our work we replace their discrete state representations with learned representations particularly designed to estimate elapsed time to improve the novelty estimation.
The time distance between two states is used to build an abstraction level on top of the raw observations by grouping temporally close states.
Equipped with this capability, our model can decide about the acceptance or rejection of states for the archive memory and maintain additionally exploration statistics.
Contribution .
This work attempts to improve the exploration problem by introducing a learnable novelty estimation method that is applicable to arbitrary inputs.
In the experiment section, we demonstrate the reliability of our method by comparing its results with native Go-Explore and more broadly with several other exploration-based and baseline approaches.
The main contributions of this paper are the following:
We introduce a new novelty estimation method consisting of a siamese encoder and a timemyopic prediction network which learns problem-specific representations that are useful for time prediction.
The time distances are later used to determine novelty which generate a time-dependent state abstraction.
We implement a new archive for Go-Explore that includes a new insertion criterion, a novel strategy to count cell visits and a new selection mechanism for cell restarts.
P ROBLEMS OF G O -E XPLORE
Go-Explore maintains an archive of saved states that are used as milestones to be able to restart from intermediate states, hereby prevent detachment and derailment (as discussed in Ecoffet et al.
(2021a)).
It generates its state representation by down-scaling and removing color (see Figure 2 left).
The exact representation depends on three hyperparameters (width, height, pixel-depth), which have to be tuned for each environment.
If two distinct observations generate the same encoding they are considered similar and dissimilar otherwise.
Thus, all possible states are grouped into a fixed number of representatives, which leads to overlap-conflicts when two distinct observations receive the same encoding.
In these cases one of the states has to be abandoned, which might be the reason that for the
Atari environment Montezuma‘s Revenge only 57 out of 100 runs reached the second level in the game (as reported in Ecoffet et al.
(2021a)).
We conjecture that their replacement criterion favors a certain state over another, so the exploration will be stopped at the abandoned state.
This can result in decoupling an entire state subspace from the agent’s exploration endeavor.
A related issue emerges by ignoring the spatio-temporal semantics between states that are grouped together into a single representation.
The down-scaling method is just compressing the image information without considering its semantic content.
The consequence is a replacement criterion that resolves archive conflicts between states that are neither spatially nor temporally in a close relationship.
Therefore a conflict solver has to resolve illogical and non-intuitive conflicts, because in these cases it is not obvious which state should be favored.
We have no information about which potentially reachable states are more promising.
On top of that, the cell representation is only suitable for states represented by small images.
If we have images with higher resolutions the representations could get either abstract (and hereby limiting the exploration progress) or too narrow resulting in an overflowing archive.
Moreover and from a general point of view, it is not clear how we could usefully down-scale an input observation that consists of partial or no image information at all.
L EARNING TIME - MYOPIC STATE REPRESENTATIONS
The basic idea of Go-Explore is to save intermediate results, so that the environment state can be restored from a memory to try new action sequences and obtain different outcomes.
However, the difficulty is to decide when to store a state for returning.
Go-Explore solves this by a heuristic that lead to some non-intuitive decisions when dealing with representation conflicts as discussed in the previous section.
In the following we show how state representations can be learned that are particularly designed to predict the time progress.
Equipping Go-Explore with this model will avoid archive conflicts and gives a better control over the novelty estimation problem.
We call our method time-myopic since it is trained to predict the elapsed time only up to a particular distance.
3. P REPROCESSING AND SIAMESE ENCODER
As a first step, we preprocess for every timestep t a stack of the last three RGB observations o t , o t − 1 , o t − 2 .
For this we convert each observation into a single gray-scale frame to generate a compressed input format (see Fig. 1).
The result ¯ o t consist of three color channels where each channel represents one gray-scale observation.
This format captures time-critical information and allows us to infer properties such as velocity and acceleration of objects.
Given a preprocessed observation ¯ o t , we apply a siamese convolutional neural network (CNN)
Φ θ to obtain a latent vector encoding z t
[Equation]
The exact architecture of the CNN Φ θ is shown at the top right in Figure 1.
The goal is to learn a useful embedding that captures the information to accurately predict the elapsed time k
between two given observations ¯ o t and ¯ o t + k .
We choose siamese networks since they demonstrated good results (Koch, 2015; Ermolov and Sebe, 2020; Chen et al., 2021) in distinguishing deviations between distinct inputs or respectively capturing similarity.
3. T IME - PREDICTION NETWORK
After the encoding procedure, a pair of observation encodings ( z t , z t + k ) allows us to estimate the elapsed time between the elements of a pair.
For this, we feed the difference between z t and z t + k into another fully-connected multi-layer neural network f θ that outputs a real number.
The whole time prediction network is written as Ψ θ and includes a normalization (see bottom right Fig. 1)
[Equation]
In Equation (2) the model predicts the time distance from the starting point z t to the destination z t
+ k where a swap can result in a different outcome.
We obtain the myopic property by normalizing the output with the function g ( x ) = 1 − e − x that allows us to specify a prediction range [0 , L ] for the normalization interval [0 , 1] .
When we want to obtain the predicted time distance k we need to multiply the normalized output with the upper bound L and vice versa for converting a distance k to the internal representation
[Equation]
3. L OSS FUNCTION AND ITS IMPLICATIONS
The time prediction loss objective L time ( θ ) minimizes the mean squared error between the predicted time distance and the true distance k
[Equation]
where the correct distance k is known from the sampled trajectories after the environment interaction.
The neural network computation includes the normalization g ( x ) to prevent exploding gradients and introduces the upper time window bound L that limits the network‘s expressivity beyond L timesteps.
This constraint simplifies the task, since correct forecasts of longer periods of time become unimportant (Makridakis et al., 2018).
The myopic view is helpful to reliably estimate novelty, because the model does not need to handle a precise time measurement between states that are far away from each other.
By considering only local distances, the predictions get easier and they are more reliable.
So when the network encounters a state-pair with a large distance k > L , we do not care about the exact true distance.
But instead, the model should indicate that the states are far away from each other by outputting the upper bound L .
3. T IME DISTANCE IS POLICY DEPENDENT AND DIRECTED
Each singular timestep represents a state transition on the underlying MDP where the time-related reachability is dependent on the current policy.
This means that two distinct policies could reach a certain state with a different number of timesteps.
Also, since time distances are directed we have to input our encodings ( z A , z B ) in the right order into Ψ θ .
For intuition, Figure 2 (right) shows a visual example where a state A is on top of a small cliff and point B is at the bottom of it.
To reach B from
A an agent could use the shortcut and jump down the cliff, but it might not be possible to jump back up.
Therefore the agent needs to find a different path that might increase the elapsed time to reach
A from B .
For that reason we assume that the distances of our time prediction function can yield different results for Ψ
θ ( z A , z B ) and Ψ θ
( z B , z A ) .
T IME - MYOPIC G O -E XPLORE
To integrate our learned representation model from the previous section into the native Go-Explore method, we have to make some adjustments, since our state encodings are continuous (and no longer discrete).
This makes it harder to decided similarity between two distinct states.
In the following we explain how this is achieved.
4. A RCHIVE INSERTION CRITERION
The time prediction capability of Ψ θ allows us to propose a new archive criterion.
Our criterion is an insertion-only method which adds a state to the archive when it is novel enough. In this way the detachment problem is entirely solved by not abandoning archive states.
We initialize the archive by inserting the encoding z c 1 of the environment‘s start state.
This entry will begin the exploration effort by searching for novelty around the starting point.
In order to do that the agent samples trajectories from the restored state c 1 where we collect new states that we call archive candidates.
A new candidate encoding z K is evaluated with every archive entry z C by the time prediction function.
The predicted value Ψ θ ( z C , z K ) is thresholded by some hyperparameter T d to determine the acceptance or rejection of the current candidate.
If the threshold is surpassed for every comparison, the candidate K is added to the archive.
Note, that we choose the time distance direction Ψ θ
( z C , z K ) since we want to move away from the archive entries.
When this happens, we conclude that the agent has reached a currently unknown part of the state space which has a sufficient novelty with respect to the archive-known subspace.
In this way, the candidate evaluation gains a global view on the exploration progress instead of considering a local trajectory-based perspective (Badia et al., 2020; Savinov et al., 2018).
A short example is shown in Table 1. [Table]
4. V ISIT COUNTER
To ensure successful progression in the exploration, it is common practice to track the number of cell visits C visits for every cell C in the archive.
With respect to the return selection, the visit counter of a cell increases by one when it is selected as a starting point.
Furthermore, the visit counter increments when the time distance to an archive candidate is lower than a visit threshold T v .
This evaluation runs simultaneously to the application of our insertion criterion where we compute all time distances to the candidate.
4. C ELL SELECTION CRITERION
Native Go-Explore made the design choice to replace cell entries with small scores to states with larger scores.
This significantly boosts the exploration by abandoning states which might have been sufficiently explored.
Time-myopic Go-Explore does not have this ability, because the state representations are continuous and the encodings of two states with weak spatio-temporal semantics are far away from each other.
Also, our method should not overwrite archive entries, because they could be inserted again with clean visits statistics.
To bias exploration towards cells with larger scores, we calculate and combine the native selection weight W visit with our score weight W score that contains the reached cell score C score (sum of undiscounted cumulative reward). Both quantities ( C visits , C score ) are stored in the archive for every cell C .
[Equation]
The outer maximum in W score ensures that states with lower scores are explored as well (with chosen hyperparameter α = 0 . 075 ).
The inner maximum normalizes the experienced scores between zero and one.
T ECHNICAL DETAILS FOR TRAINING
In order to improve the model quality we explain next three additional training routines that enhance the time prediction of our model.
5. S IMILARITY AND DISSIMILARITY
Optimizing only on close-by pairs (e.g. with time distance k ≤ L ) will lead to wrong estimates for distant pairs (i.e. k > L ), which might be the majority of cells.
Thus we have to ensure that our dataset includes also dissimilar pairs where the observations are at least L timesteps away from each other.
The distance of a dissimilar pair is trained on the value that corresponds to the maximal time estimation L , which does not represent the actual distance.
Instead it signals a sufficiently large temporal space between them.
In this way, we try to find encodings such that the embedding region around a state only includes other encodings that are within the defined time window [0 , ..., L ] .
5. A VOIDING TEMPORAL AMBIGUITY
Suppose there are two observations ¯ o t + k 1 and ¯ o t + k 2 that happened at different points in time, but which are pixel-wise identical.
To define a single distance to some other observation ¯ o t , we will use the minimum of k 1 and k 2 .
To quickly identify pixel-wise identical observations we are using the
MD5 hash function (Rivest, 1992).
5. P ROXY CELLS AND LOCAL DATASETS
Usually the time prediction model would be trained on trajectories that always start with an archive state.
To extend the training data we additionally generate trajectories (only for training) that start from so-called proxy cell states that are temporally close to an archive cell.
We collect these proxies by choosing randomly states in the time distance interval [ T p-low , T p-high ] to their respective archive cell and replace them periodically.
To further increase variability of the dataset, we add small local datasets for each cell that add some data points within its proximity.
Every dataset holds a few hundred pairs where we store the time distance between the cell state and a temporally close state.
This is necessary because otherwise our network would forget about certain cells and their neighboring states since they are not visited anymore due to the selection weighting W = W visits ∗ W score .
E XPERIMENTS
The experiment section covers the following topics: in Section 6.1 we study the encoder properties and assess how well the time can be predicted.
In Section 6.2 we compare our approach, the original
Go-Explore and other related methods.
In Section 6.3 we analyze the archive for the native and our proposed time-myopic Go-Explore.
6. W HAT DOES OUR MODEL LEARN ?
To demonstrate the properties of our model, we re-create an experiment from Ermolov and Sebe (2020) which is shown in Figure 3.
A representation-learning network is trained on 400k observations from the Atari environment Montezuma’s Revenge where the training data is gathered by a random actor at the environment‘s start state.
After optimization, the network is asked to encode the observation sequence from the trajectory shown in Figure 3 (top-left).
Most of the encodings are extrapolated, because a random policy is not able to reliably execute the action sequence that generated the observations.
Therefore an extrapolation starts roughly between the checkpoint 3 and 4.
In this experiment our model uses 9k observations which are sufficient to show a good result.
The 32dimensional encodings are projected with the t-SNE method into a two-dimensional space where it uncovers the interesting relationship between the data points.
Temporally close states are grouped together and are strung on a thread while the sequence unfolds.
The distance between two imminent states does not collapse and it provides useful semantics for time measurements.
Remember that the chosen trajectory has no greater meaning for our model and it is perceived as arbitrary like any other possibly selected sequence.
Subsequently, the rich structure is also present when performing PCA on the encodings (see Appendix Figure 5).
The time evaluation demonstrates good results where the network has training data.
However, the extrapolation capability on time distances is limited.
But surprisingly we can see that the encoder even places unseen states close to their temporal neighbors resulting in local semantic integrity.
At some point the extrapolation of time distances becomes unreliable which will improve with more novel data for optimization.
Once the network was trained on more data during a complete run, the prediction quality gets a lot better (see Appendix Figure 6).
6. C OMPARISON ON HARD EXPLORATION ENVIRONMENTS
We evaluate our method on the hard exploration environments Montezuma’s Revenge, Gravitar,
Frostbite (Atari) and compare it with (i.) related methods (ii.) and native Go-Explore.
We prepare our experiments by adjusting the natively used random action-repeating actor (Ecoffet et al., 2021a).
Time-myopic Go-Explore decreases the actor’s action repetition mean µ from 10 to 4 .
This is necessary since the native method does not care about learning a state representation while our learned model depends on a robust data collection for the time predictions.
Native Go-Explore has
[Table]
[Table]
[Table]
[Table]
[Table]
the advantage that it can act more greedily, because the representation heuristic is always reliable and therefore can be exploited by acting more risky.
Also, native Go-Explore uses the originally recommended down-scaling hyperparameters ( h = 8 , w = 11 , dp = 8) for Montezuma’s Revenge and the dynamic down-scaling (recompute every 500k frames) only for the other environments (Montezuma’s Revenge with dynamic down-scaling performs worse).
For native Go-Explore we are using the official implementation.
Our time-myopic Go-Explore variant runs on one A100 GPU and needs roughly 8-10 hours for 5M frames depending on the archive size.
[Table]
dp
[Table]
[Figure]
The result shows the practicality of time-myopic Go-Explore since it is better than most of the methods for Montezuma’s Revenge and Gravitar while it only has seen 2% of their frames (1M vs 50M frames).
It also provides a good performance on Frostbite surpassing PPO, RND, EX2 and ICM.
Moreover, time-myopic Go-Explore is able to keep up with the performance of native Go-Explore (using the domain-aligned representation heuristic) and even exceeds it within 1M frames for the environment Gravitar.
As far as we know the results of Gravitar for 1M frames are state-of-the-art.
6. A BLATION STUDY
Next we provide a closer look at the archive properties.
First, we compare the difference in the archive size between native Go-Explore and our approach (see Table 3).
The table shows the mean number of cells (20 runs) in the archive when the agent reaches a certain game score [100 , 400 , 500 , 2500] in Montezuma’s Revenge.
The native archive size explodes after reaching a score of 400 while our approach shows a more stable progression.
The data also validates smaller archive sizes as a result of increasing the hyperparameters ( L , T d ).
In the Appendix, a figure shows more precisely when and how the prediction model decides to add archive entries.
We observe in our experiments a similar pattern for the environment Gravitar which uses the dynamic down-scaling heuristic.
The native archives agglomerate an enormous amount of archive entries.
After 1M frames for 20 runs, the mean size results in 7376 cells while time-myopic Go-Explore holds 381 entries and is achieving a higher score.
Secondly, both methods are evaluated on the similarity within the created archives (see Figure 4).
The time distances between all cell observations will provide an interesting similarity measurement.
The model predictions in Figure 4 confirm that the native archive yields a lot more similarity than our approach.
This leads to inefficient exploration, because based on the cell selection criterion every cell needs to be sufficiently visited, no matter how few environment transitions are between them.
Our archives cover the state space with less cells.
6. L IMITATIONS
Due to the queries to the archive, our algorithm runtime increases currently non-linearly with the number of entries.
This makes long runs or runs where the archive grows fast computationally expensive.
This happens, because our approach requires to compute time distances to every archive entry in order to evaluate new cell candidates or to update the visit statistics.
So, in the future, we will make these queries more efficient to make the method applicable to even larger environments and runs.
R ELATED WORK
Hard exploration problems like the Atari environment
Montezuma’s Revenge are known for their large state spaces and sparse reward functions.
A lot state-of-the-art reinforcement learning algorithms (Schrittwieser et al., 2020; Kapturowski et al., 2019; Schulman et al., 2017) have difficulties in achieving a good performance on these tasks, so several ideas have proposed towards a solution.
The literature contains several approaches related to our work that deal with unsupervised- and representation learning combined with intrinsic motivation and exploration.
Playing hard exploration games by watching YouTube (Aytar et al., 2018).
In this work the authors introduce a neural network architecture in order to learn a categorical time classification between two distinct observations.
Their network is used to generate an intrinsic reward signal to facilitate imitation learning of human demonstrations while we are using it to globally model the exploration process.
Solving sparse reward environments using Go-Explore with learned cell representation (Bjørsvik, 2021).
This approach also extends the Go-Explore (Ecoffet et al., 2021a) method by replacing the representation heuristic with a learned state representation.
They employ a Variational
Autoencoder (VAE) (Kingma and Welling, 2013) to encode every seen state into a latent vector space.
Later on, the encodings are used for a k-means clustering procedure where a cluster center stands for an entry in the archive memory.
Latent world models for intrinsically motivated exploration (Ermolov and Sebe, 2020).
This paper optimizes a siamese network that clusters temporal imminent states in the embedding space by minimizing the mean squared error between them.
In addition, there is the need for an extra structure constraint in order to prevent a collapse of the representation to a constant vector.
The resulting encodings are used for the generation of an intrinsic reward signal.
Episodic curiosity through reachability (Savinov et al., 2018).
The paper introduces a model architecture with a logistic regression capability to differentiate between novel and familiar state pairs where novelty is defined by a minimum time distance of k steps.
The complete model (including a siamese encoder and comparison network) is only able to decide whether an encountered pair is novel or not; without the ability to evaluate it on a continuous basis.
This estimation is utilized to generate a positive intrinsic reward signal when a policy encounters new states.
Never give up: learning directed exploration strategies (Badia et al., 2020).
The proposed episodic novelty module starts empty and fills itself with state encodings when the agent interacts with the environment.
Every state gets evaluated by a k-nearest neighbor criterion with the similarity measure of the Dirac delta kernel to compute the rewards with respect to the similarity distance.
The goal is to insert as many novel states as possible which then facilitate exploration.
C ONCLUSION
To add flexibility to and possibly improve Go-Explore we studied how its representation heuristic can be replaced by a time-predicting neural network.
Experiments show that the new state representation is able to track the global exploration effort and moreover recognizes ongoing progress for this task.
In comparison to native Go-Explore, our method can reduce the archive size and covers the state space with fewer cells.
Applied to hard exploration environments, such as Montezuma’s Revenge we observe good performance compared to previous exploration-based methods while using much fewer observations, even creating better results than Go-Explore on the game Gravitar.
Overall, however our learned representation is not able to compete with native Go-Explore in terms of sample efficiency.
A A PPENDIX - S ECTION
[Table]
[Table]
t
[Table]
[Figure]
Algorithm 1 Go-Explore with a learned state representation
Initialize archive, dataset, agent, network for iteration = 1 , 2 , ... do
Let the agent act t timesteps in the environment starting from the selected and proxy cells
Collect data and optimize L time w.r.t.
θ
Recompute all archive cell representations: z C =
Φ θ (¯ o C ) for each trajectory = 1 , 2 , ..., N do
Transfer all observations ¯ o 1 , ..., ¯ o t into the latent representation z 1 , ..., z t
Compute all necessary time distances Ψ
θ ( z c , z 1 ,...,t )
Apply archive insertion criterion to a candidate w.r.t.
threshold T d
Increase cell visits w.r.t.
threshold T v
Collect some proxy cells w.r.t.
threshold [ T p-low , T p-high ] if candidate is accepted then
Add candidate to archive end if end for end for