Guided Exploration in Reinforcement Learning via Monte Carlo Critic Optimization
Abstract
The class of deep deterministic off-policy algorithms is effectively applied to solve challenging continuous control problems.
However, current approaches use random noise as a common exploration method that has several weaknesses, such as a need for manual adjusting on a given task and the absence of exploratory calibration during the training process.
We address these challenges by proposing a novel guided exploration method that uses a differential directional controller to incorporate scalable exploratory action correction.
An ensemble of Monte Carlo Critics that provides exploratory direction is presented as a controller.
The proposed method improves the traditional exploration scheme by changing exploration dynamically.
We then present a novel algorithm exploiting the proposed directional controller for both policy and critic modification.
The presented algorithm outperforms modern reinforcement learning algorithms across a variety of problems from DMControl suite.
1. Introduction
In reinforcement learning, exploration is a vital component of policy optimization.
The method chosen to be an exploration strategy defines the interaction with the world, thus influences the final agent’s success being key in solving continuous (Zhang & Van Hoof, 2021), navigation (Mazoure et al., 2020) and hierarchical problems (Vigorito, 2016).
On a high level, all exploration methods can be divided into undirected and directed ones (Thrun, 1992).
The undirected methods provide random exploratory actions based on desired exploration-exploitation trade-off, while directed algorithms rely on information provided by a policy or a learned world model.
In real world, humans and animals seldom rely on random exploration of the environment, always pursuing some intrinsic motivation as safety (Tully et al., 2017), curiosity (Berlyne, 1966; Kidd & Hayden, 2015) or uncertainty minimization (Gershman, 2019).
Equivalents of these psychological phenomena are successfully applied within corresponding research directions of reinforcement learning, forming the class of intrinsically-motivated algorithms (Garcıa &
Fern´andez, 2015; Pathak et al., 2017).
A scheme of such intrinsically motivating guided exploration is depicted in
Figure 1, showing different directions of policy parameters change for the external- and intrinsic-reward objectives.
In the context of continuous control problems, the class of deep deterministic off-policy methods gains high popularity in the reinforcement learning community due to its implementation simplicity and state-of-the-art results.
However, from an exploration perspective, such algorithms as DDPG (Lillicrap et al., 2015) and TD3 (Fujimoto et al., 2018) use
Gaussian or time-dependent Ornstein-Uhlenbeck noise that is applied to deterministic action.
While being a simple
[Figure]
and rather effective exploration tool, the methods based on random noise suffer from three limitations.
Firstly, in high dimensional environments random exploration is an inefficient strategy to achieve certain regions of interest in the state-space that can lead to success (Burda et al., 2018).
Secondly, the algorithms discussed apply noise with the same mean and deviation during the whole period of policy optimization.
Being a crucial instrument in the beginning of parameter search, excessive exploration may hurt the policy performance to reach its optimal condition.
Finally, the aforementioned methods apply noise of the same magnitude for all actions, whereas actions in continuous control often relate to the entities of different scales.
To illustrate the sub-optimality of conventional random exploration and justify our motivation we consider the TD algorithm performance on two continuous control domains,
Walker2d-v2 and Humanoid-v2 (Brockman et al., 2016).
We compare the original version of TD3 and a variant without any noise applied during action selection and calculation of a critic value.
Original TD3 provides poor performance compared with the version without any exploration noise (Figure 2).
This simple experiment demonstrates that current Gaussian-based exploration can hurt the agent’s performance.
Nevertheless, the total absence of exploration may also lead to lower episodic reward, as our later experiments show.
We aim to develop an effective method of directed exploration that enhances the results of deterministic offpolicy algorithms.
We address the mentioned weaknesses of random exploration by introducing a directional controller that is able to guide a policy in a meaningful exploratory direction.
Specifically, we propose to use an ensemble of Q-function approximations trained to predict Monte Carlo Q-values as such a controller.
By optimizing multiple independent predictions and using the action gradient from calculated variance we are able to obtain an uncertainty estimate for a given state.
Based on this gradient we provide an exploratory action correction towards the most unexplored environment regions.
The contribution of this paper is twofold.
First, we present a method for a guided exploration that can substitute Gaussian noise and be incorporated into any off-policy deterministic algorithm.
We show that the proposed exploration improves over other exploration methods on a set of continuous control tasks.
Second, we present a novel algorithm that exploits the proposed uncertainty-based directional controller for both actor and critic parts of model architecture.
The proposed method demonstrates superior results compared with modern reinforcement learning algorithms on a set of tasks from DMControl suite.
Following the guidelines of reproducibility of reinforcement learning algorithms (Henderson et al., 2018)
we report the results on a large number of seeds and release the source code alongside raw data of learning curves 1 .
2. Preliminaries
We consider a standard reinforcement learning (RL) setup, in which an agent interacts with an environment E at discrete time steps aiming to maximize the reward signal.
The environment is a Markov Decision Process (MDP) that can be defined as ⟨S , A , R , ρ, γ ⟩ , where S is a state space, A is an action space, R is a reward function, ρ is a transition dynamics and γ ∈ [0 , 1] is a discount factor.
At time step t the agent receives state s t ∈ S and performs action a t ∈ A according to policy π , a distribution of a given s that leads the agent to the next state s t +1 according to the transition probability ρ ( s t +1 | s t , a t ) .
After providing the action to E , the agent receives a reward r t ∼ R ( s t , a t ) .
The discounted sum of rewards during the episode is defined as a return
R t = (cid:80)
Ti = t γ i − t r
( s i , a i ) .
The RL agent aims to find the optimal policy π θ , with parameters θ , which maximizes the expected return from the initial distribution J ( θ ) =
E s i ∼ ρ π ,a i ∼ π θ [ R 0 ] .
The actionvalue function Q is at core of many RL algorithms and denotes the expected return when performing action a from the state s following the current policy π :
[Equation]
In continuous control problems the actions are real-valued and the policy π θ can be updated taking the gradient of the expected return ∇ θ J ( θ ) with deterministic policy gradient algorithm
(Silver et al., 2014):
[Equation]
The class of actor-critic methods operates with two parameterized functions.
An actor represents policy π and the
-  1 aa
Var( { q 1 ... q n } )    -  1 aa
Q ( s , ) 0.
critic is the Q-function.
The critic is updated with temporal difference learning by iteratively minimizing the Bellman error (Watkins & Dayan, 1992):
[Equation]
In deep reinforcement learning, the parameters of Qfunction are modified with additional frozen target network
Q θ ′ which is updated by τ proportion to match the current
Q-function θ ′ ← τθ
+ (
[Equation] [Equation]
where
[Equation]
The actor is learned to maximize the current Q function:
[Equation]
In this work, we focus on an off-policy version of actorcritic algorithms, proven to have better sample complexity (Lillicrap et al., 2015).
Within this approach, the actor and the critic are updated with samples from a different policy, allowing to re-use the samples collected from the environment.
The mini-batches are sampled from the experience replay buffer (Lin, 1992).
In off-policy Q-learning, actions are selected greedily w.r.t.
maximum Q-value thus producing overestimated predictions.
An effective way to alleviate this issue is keeping two separate Q-function approximators and taking a minimal one during the optimization (Van Hasselt et al., 2016).
Modern actor-critic methods (Fujimoto et al., 2018; Haarnoja et al., 2018b) independently optimize two critics Q 1 , Qwith identical structure and use the lower estimate during the calculation of the target Q ′ :
[Equation]
3. Method of Guided Exploration
On a high level, our agent consists of two components: an actor-critic part to provide a deterministic policy and a directional controller that modifies policy output action to facilitate directed exploration.
The deterministic policy π θ ( s ) is parameterized by θ and optimizes reward maximization to produce a base action a b .
The directional controller ψ optimizes auxiliary intrinsic objective to produce an exploratory action correction a e .
The policy and the directional controller are jointly optimized to produce an additive action to collect transitions for off-policy updates:
[Equation]
For the actor-critic part, we use the TD3 algorithm (Fujimoto et al., 2018) as a backbone.
3.1. Directional Controller
The directional controller DC ω ( s | θ ) is parameterized by ω and conditioned on policy parameters θ .
The proposed controller features an ensemble of Q-function approximators { q 1 ( s, a ) , ..., q n ( s, a ) } that predicts the collected Monte
Carlo Q-values.
The values for the update are sampled from a small experience replay buffer D MC with recent trajectories collected by the policy.
Given n ensemble predictions, the controller DC estimates prediction uncertainty as the ensemble disagreement:
[Equation]
where q i ( s, a ) =
E s ∼D MC ,a ∼ π θ [ R ] , i ∈ [1 ..n ] .
This disagreement reflects both epistemic uncertainty of controller parameters and aleatory uncertainty of the collected Monte
Carlo Q-values.
During optimization, controller’s objective is to reduce uncertainty in a supervised fashion by minimizing square distance between the predicted and collected returns:
[Equation]
where ( s, a ) is a state-action pair sampled from D MC with the corresponding Monte Carlo Q-value Q MC ( s, a ) .
Taking the gradient of the controller w.r.t.
action, we obtain the direction towards maximizing the uncertainty under current controller parameters ω :
[Equation]
This gradient value is at the core of exploratory action a e , as it identifies the direction towards the most unexplored environment regions.
Figure 3 depicts the surface of the uncertainty estimation value returned by ψ ( s ) and the critic prediction Q ( s, · ) for the point mass-easy task, where |A| = [Figure] [Figure] [Figure]
[Figure]
Noise Scale ( )
[Figure]
[Figure] [Figure]
The visualization is performed after 1e5 time steps with fixed state s and a set of actions a ∈ [ a MIN , a MAX ] .
The surfaces show different highest points, making a b and a e have different directions.
We use Monte Carlo Q-value approximation as a directional controller for two reasons.
First, it is differentiable w.r.t action, allowing to obtain action gradient.
Second, in contrast with model-based dynamics (Janner et al., 2019) and curiosity (Pathak et al., 2017) approaches, which require either the next state or the next action to compute the intrinsic signal, we need only the current state-action pair to obtain a plausible action direction.
Since the directional controller to modify the exploratory action is applied, we do not have an access to the next transition as in approaches that incorporate intrinsic signal during the off-policy update step.
3.2. Calculating action correction
During policy optimization the agent sequentially performs a base action a b ∼ π θ ( s ) .
Given the state s and policy parameters θ , the directional controller provides the base action gradient towards exploration objective ∇ a b ψ ω ( s | θ ) .
Here we describe the procedure of obtaining action correction a e based on this gradient.
To connect gradient value ∇ a b with action scales we perform the following scaling procedure:
[Equation]
where ϵ is denormalization constant and ζ is a scaling factor.
The denormalization constant ϵ is to scale normalized gradient values to the practical magnitude of actions for a given task.
It is possible to set this constant to the value that corresponds to exploration magnitude used in (Lillicrap et al., 2015; Fujimoto et al., 2018), obtaining a directional vector of a scale required.
However, with this only modification action correction vector would be fixed in its magnitude during the learning process.
As a solution, we set ϵ to the magnitude of fully exploratory vector of random actions
[Figure]
sampled uniformly:
[Equation]
with the following multiplying by the dynamic scaling factor ζ .
We pose two requirements on the scaling factor:
• It should be bounded with ζ i ∈ [0 .. 1] , i ∈ [1 .. |A| ] , with 0 corresponding to the absence of exploration and 1 corresponding to the random action selection.
• It should change dynamically within the policy optimization.
To satisfy both requirements we support two statistical quantities during the learning process: the running deviation of ∇ a b for the last N time steps σ N ( ∇ a b ) and its maximum value max [ σ ( ∇ a b )] for all seen deviation gradient values during the learning, resulting in:
[Equation]
Large values of gradient deviation between adjacent actions from a small running window of size N show uncertainty of the ensemble thus reflecting the need for more intensified exploration.
The scaling factor is of dimension |A| , facilitating keeping the individual scale for each element of a continuous action vector.
The dynamics of exploratory action a e during the learning process on different tasks is depicted in Figure 4a.
In the beginning of the training, the scaling factor is close to maximum action bound enhancing aggressive exploration.
During the policy and the directional controller optimization ζ decreases leading the policy to more exploitation-inclined behavior.
Notably, the dynamics of the scaling factor are not identical between environments.
An example of action correction values a e for the walker-run task are depicted in
Figure 4b.
DC
Env 𝑎 e 𝑠 𝑎 b + 𝑄 MC
Replay Buffer
DC
MSE 𝑄 MC 𝜇
π 𝑄 π 𝑎 𝑠
[Figure]
4. MOCCO Algorithm
Based on the presented technique of guided exploration, we propose a novel deep reinforcement learning algorithm
Mo nte C arlo C ritic O ptimization (MOCCO) that incorporates an ensemble of Monte Carlo critics not only for the actor, as an exploratory module, but also for the critic to alleviate Q-value overestimation.
Several works have studied Qvalue overestimation in continuous control setting and have presented techniques to alleviate the issue (Ciosek et al., 2019; Kuznetsov et al., 2020; Kuznetsov & Filchenkov, 2021).
Here, we propose to use a mean from the ensemble of Monte Carlo values as a second pessimistic Q-value estimate during critic optimization, resulting in the following critic’s objective:
[Equation]
where Q MC = µ ( { q 1 , ..., q n } ) , and β is a coefficient controlling an impact of the pessimistic estimate.
For the given state-action pair ( s, a ) the critic estimate Q ( s, a ) is generally greater than the corresponding Monte Carlo estimate
Q MC , as the latter predicts estimates of the past sub-optimal policies.
To illustrate this, we measure the following quantities during the learning process on tasks Walker2d-v2 and
Hopper-v2:
• TD-based bootstrapped Q-value approximation as averaged critic Q prediction.
Only a single critic is optimized during the TD optimization.
Algorithm
[Table]
[Equation] .., q k } 3: Initialize replay buffer B , episodic buffer B E 4: Initialize smaller buffer B MC for the most recent steps 5: for t=1 to T do 6:
Select action with guided noise a = a b + a e , 7: a b ∼ π θ π ( s ) , a e ∼ DC ω 8:
Receive next state s ′ , reward r , terminal signal d 9: if d then 10: for i=1 to |B E | do 11:
Calculate discounted episodic return R i 12:
Store ( s i , a i , r i , s ′ i , d i ) in B 13:
Store ( s i , a
i , R i ) in B MC 14: end for 15:
Free B E 16: end if 17:
Sample mini-batch from B : [ s b , a b , r b , s b ] and 18: update critic Q : J Q =
( Q − Q ′ )
2 + β ( Q − Q MC )19:
Sample mini-batch from B MC : [ s b , a b , R b ] and 20: update DC ω :
J DC =
(cid:80) ki ( q i − R b )21: if t mod 2 then 22:
Update policy π πθ 23:
Update target critic θ Q ′ ← τθ Q + (1 − τ ) θ Q ′ 24: end if 25: end for 26: return θ π
• True Q-value estimate as a discounted return of the current policy starting from given state-action pair.
• Monte Carlo Critic Q-value estimate as an averaged prediction of Q MC .
All three quantities are averages across the batch size ofthat are collected each 5e3 time steps and reported from multiple seeds.
Figure 5 shows the dynamics of predictions on 1M time steps.
Monte Carlo prediction (Q-MC) has lower value than both TD-based (Q) and true Q-estimate (Qtrue) values, while TD-based prediction is generally higher than the true estimate.
In reinforcement learning, Monte Carlo estimates have high variance and low bias, whereas one-step TD methods have less variance but can be biased.
Here, we combine both methods during Q-function optimization.
Empirically we show that the true Q-value estimate lies between Q and
Q MC , therefore it is beneficial to use both estimates to balance between over- and underestimation.
The role of the directional controller (DC) during the exploration and critic optimization is schematically depicted in Figure 6.
During action selection, DC provides directed exploration i.e. it is applied on-policy.
During off-policy
[Table] [Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
update steps, DC is used to provide a second estimate for current Q-function optimization.
Practically, the MOCCO algorithm is based on TD3 with the following differences: (1) it uses guided exploration during action selection; (2) it does not use second TD critic; (3) the mean of MC-critics ensemble is used during the critic optimization.
Full pseudo-code is presented in Algorithm 1.
5. Experiments
First, we demonstrate that the proposed method improves conventional random noise-based exploration using TD algorithm.
Next, we show experimental results for MOCCO.
We perform an ablation study to identify the impact of each proposed algorithmic component on final success and demonstrate the comparative evaluation results.
5.1. Guided Exploration for Off-Policy Deterministic Algorithms
In this experiment
[Table]
we show that guided exploration improves over the traditional Gaussian-based exploration method.
To do so, we use TD3 as a baseline algorithm and vary the type of applied exploratory noise during the action selection process.
Table 1 shows the results of the following scenarios: actions are sampled without noise (no [Table] [Figure] [Table]
[Figure]
[Table]
[Figure]
[Table] [Figure] values. expl), with Normal Gaussian noise (normal), temporally correlated noise drawn from an Ornstein-Uhlenbeck process (OU), and with proposed guided exploration method (GE).
For normal Gaussian and Ornstein-Uhlenbeck noise, we use parameters reported in (Haarnoja et al., 2018b; Lillicrap et al., 2015) correspondingly.
We run each algorithmtimes with different random seeds.
Within each run, the reported value is the mean of 10 evaluations of the same policy from different environment initialization.
Results demonstrate higher rewards of guided exploration over the conventional approaches for all environments except hopperhop.
5.2. MOCCO: Ablation Study
The aim of this experiment is to identify the impact of each component on the overall success of the presented algorithm.
We study the contribution of guided exploration as a substitution of the Gaussian noise (TD3 + GE), the contribution of the proposed critic objective featuring Monte
Carlo critic estimate (TD3 + QMC), and of both features combined (MOCCO).
Figure 7 shows results for walker-walk, walker-run, hopper-
[Figure]
[Table]
stand, hopper-hop on 5 random seeds.
Results show that each component improves the results of TD3 algorithm on all tasks and a combination of features provides better performance than their sole contributions on 3 out of 4 tasks.
Next, we vary hyperparameters introduced by MOCCO to identify algorithm robustness on two tasks: walker-walk and hopper-hop.
We study different values of the coefficient controlling MC critic impact ( β ), the size N of the buffer used for calculating the running deviation of action gradient σ N ( ∇ a ) [Table] and the size of reduced replay buffer B MC on which the ensemble of MC critics is trained.
Figure 8 shows that MOCCO is robust to the hyperparameter change, except the case of varying β for hopper-hop.
We demonstrate comparative results of MOCCO algorithm on 6 control problems from DMControl (Tassa et al., 2018) benchmark: point mass-easy, walker-walk, walkerrun, pendulum-swingup, hopper-stand, hopper-hop.
We compare the proposed approach with off-policy algorithms
DDPG, TD3, SAC (Haarnoja et al., 2018a) and on-policy
[Table] (Schulman et al. [Table] [Table]
For off-policy algorithms, we run 1M environment time steps on each environment, collecting episode scores for every 2e3 steps.
Each episode score is an average of 10 runs of a policy without exploration from different environment seeds.
Each algorithm is run 10 times with different seeds with reported standard deviation.
For PPO, we run the training process 10 times with different environmental and algorithmic seeds with the following averaging.
We use the official implementation of TD3 as a baseline.
For
DDPG, we use the implementation from TD3, denoted as ”DDPG”.
We extend the TD3 code to entropy optimization for SAC deriving.
For PPO results we use the implementation from (Kostrikov, 2018).
We use Adam optimizer (Kingma & Ba, 2014) with the learning rate 3e-4 for all algorithms.
For a fair comparison, we use the same network parameters from the (Fujimoto et al., 2018).
All networks have 2 hidden layers of sizeand ReLU non-linearity (Glorot et al., 2011).
For SAC we run two versions, first with fixed entropy coefficient equal to 0.2 (proposed in (Achiam, 2018)) and auto tunable entropy (SAC- α ) from (Haarnoja et al., 2018b).
We use mini-batch size 256 for all algorithms.
For MOCCO, we set the size of D MC to 1e5 transitions, and the size of buffer N for calculating deviations used in the scaling factor ζ to 1000.
We use 3 critics in the ensemble as our experiments have not provided benefits from an increased number of critics.
The β coefficient controlling an impact of MC-critic is set to 0.1.
Table 2 reports the average of episodic scores for the last 10 episodes.
The corresponding learning curves are presented in Figure 9.
MOCCO outperforms other approaches, sometimes with significant margins, e.g. for pendulum and hopper-stand.
6. Related Work
The problem of efficient exploration has a long-standing history in reinforcement learning.
Early approaches suggest incorporating random exploratory strategies (Moore, 1990;
Sutton, 1990; Barto et al., 1991; Williams, 1992) which have theoretical grounds but are not always scalable to complex environments with high-dimensional inputs.
The broad class of directed exploration algorithms, first proposed in (Thrun, 1992), studies an approach of guiding a policy towards certain regions with specific knowledge of the learning process.
Numerous works on directed exploration study intrinsic reward, where the learning process relies on some intrinsic signal.
Examples of exploration based on intrinsic reward include algorithms based on information gain (Little & Sommer, 2013; Mobin et al., 2014), curiosity (Deci et al., 1981;
Pathak et al., 2017), and uncertainty-minimization (Schmidhuber, 1991; Houthooft et al., 2016).
(Badia et al., 2019) propose to use episodic memory as a source of the intrinsic signal and optimize multiple policies, some of which are guided by exploratory goals and others are fully exploitative.
In contrast with many intrinsic-reward approaches, our method does not modify the reward with additional dense signal nor modifies the policy, but rather optimizes the intrinsic objective independently only to correct exploratory action.
The work of (Pathak et al., 2019) shows that exploration can be key in achieving high sample efficiency required for real-world setup.
The authors use an ensemble of forward dynamics models that produces disagreement as an intrinsic reward.
Incorporation of such a disagreement signal results in an effective exploration, allowing robots to solve object interaction tasks from scratch in real-time.
Apart from the directed exploration based on intrinsic objective, several works have proposed methods with a different perspective.
(Ciosek et al., 2019) addresses the notion of pessimistic underexploration that comes from optimizing a lower bound in critic update.
By approximating the upper bound of state-action function and using it during exploration the proposed method avoids underexploration and achieves higher sample efficiency.
Some works study the approach of exploration in policy parameter space rather than in action space (van Hoof et al., 2017; Fortunato et al., 2018;
Zhang & Van Hoof, 2021).
Finally, a number of works study exploration under goal-reaching angle, where the agent explores environment by learning to achieve seen (Florensa et al., 2018), generated (Nair et al., 2018; Sukhbaatar et al., 2018), or specifically unseen (Mendonca et al., 2021) state regions.
A comprehensive review of exploration in reinforcement learning can be found in (Amin et al., 2021).
Following the suggested taxonomy, the method presented in this paper falls into the category of ”reward-free intrinsically-motivated” exploration i.e. not using an extrinsic reward for exploratory purpose, but relying on intrinsic signal to explore novel world regions.
7. Discussion
We presented a method for directed exploration that improves off-policy deterministic algorithms by adding exploratory action correction to the base policy action.
By using a differential controller conditioned on policy parameters we direct exploration towards the regions of interest and dynamically calibrate the magnitude of exploratory correction during the learning process.
The proposed exploration method does not require rigorous hyperparameter turning due to the dependence on a learnable intrinsic signal that reflects given environmental uncertainty.
We provide empirical results that validate the efficacy of the proposed method on a range of continuous control tasks.
Our approach achieves a higher reward than methods dependent on a random noise.
We further presented MOCCO, a novel deep reinforcement learning algorithm based on the proposed exploration method.
Experiments showed that
MOCCO outperforms modern off-policy actor-critic methods on a set of DMControl suite tasks.
We note that the proposed directional controller based on optimizing Monte Carlo Q-values can be substituted by a different differential model.
For example, such a controller can be presented as a form of forward or inverse model dynamics, shifting the focus to model-based reinforcement learning.
Another promising direction is to present the directional controller as a differential memory module, connecting the direction of the external agent’s memory with efficient exploration.
We believe that the proposed exploration technique will help to tackle problems that require careful dynamic exploration.
Acknowledgements
The authors would like to thank Dmitry Akimov for insightful discussions.
We also thank Andrey Filchenkov for feedback during the early-stage development of the method.