S AMPLE E FFICIENT D EEP R EINFORCEMENT L EARNING VIA U NCERTAINTY E STIMATION
A BSTRACT
In model-free deep reinforcement learning (RL) algorithms, using noisy value estimates to supervise policy evaluation and optimization is detrimental to the sample efficiency.
As this noise is heteroscedastic, its effects can be mitigated using uncertainty-based weights in the optimization process.
Previous methods rely on sampled ensembles, which do not capture all aspects of uncertainty.
We provide a systematic analysis of the sources of uncertainty in the noisy supervision that occurs in RL, and introduce inverse-variance RL, a Bayesian framework which combines probabilistic ensembles and Batch Inverse Variance weighting.
We propose a method whereby two complementary uncertainty estimation methods account for both the Q-value and the environment stochasticity to better mitigate the negative impacts of noisy supervision.
Our results show significant improvement in terms of sample efficiency on discrete and continuous control tasks.
I NTRODUCTION
Deep reinforcement learning (DRL) methods have proven to be powerful at solving sequential decision-making tasks across domains (Silver et al., 2016; OpenAI et al., 2019).
Combining the flexibility of the reinforcement learning framework with the representational power of deep neural networks enables policy optimization in complex and high-dimensional environments with unknown dynamics models to maximize the expected cumulative reward (Sutton & Barto, 2018)
An important limitation of DRL methods is their sample inefficiency: an enormous amount of data is necessary and makes training expensive.
This makes applying DRL in the real world challenging, for example in robotics (S ¨ underhauf et al., 2018; Dulac-Arnold et al., 2019).
In tasks like manipulation, sample collection is a slow and costly process (Liu et al., 2021).
It is even more expensive in riskaverse applications like autonomous driving (Kothari et al., 2021).
Among the current state-of-the-art approaches to improve learning efficiency, a promising direction is to exploit the prevalence of uncertainty in the underlying DRL algorithm.
By adopting a Bayesian framework, we can consider the sampled quantities in DRL as random variables and leverage information about their distributions to improve the learning process (Osband et al., 2018).
In this paper, we consider the particular problem of unreliable supervision in the temporal difference update and the policy optimization process.
In DRL, value predictions are used to supervise the training: in temporal difference-based algorithms, they are included in bootstrapped target values which are used as labels; in actor-critic frameworks, the policy is trained to optimize them.
That these value predictions are noisy slows the learning and brings instability (Kumar et al., 2019; 2020).
The amount of noise in the supervision depends on the uncertainty of the value prediction, which evolves during the training process and depends on the state (and action) evaluated.
It is therefore heteroscedastic .
While there is an extensive body of literature focused on using the uncertainty of the value prediction to guide the exploration/exploitation trade-off (Dearden et al., 1998; Strens, 2001; Osband et al., 2016; Pathak et al., 2017; Chen et al., 2017; Osband et al., 2018;
Fortunato et al., 2019; Osband et al., 2019; Flennerhag et al., 2020; Clements et al., 2020; Jain et al., 2021; Aravindan & Lee, 2021), there are very few works focused on leveraging it to mitigate the impact of unreliable supervision.
Distributional RL (Bellemare et al., 2017) considers the value function as a distribution to be learned as such.
It is orthogonal to our proposition: we consider the uncertainty of the labels used to learn a scalar value function.
In the offline RL setting, where the dataset is limited, uncertainty-weighted actor-critic (UWAC) (Wu et al., 2021) uses inverse-variance weighting to discard out-of-distribution state-action pairs using Monte Carlo dropout (Gal & Ghahramani, 2016) for uncertainty estimation.
Closer to our work, Lee et al.
(2021) propose SUNRISE, in which each sample of the Bellman backup in the TD update step is weighted to lower the importance of the targets which have a high standard deviation.
The weights w ( s ′ , a ′ ) are computed based on a sigmo¨ıd of the negative standard deviation ˆ Q std ( s ′ , a ′ ) scaled by a temperature hyperparameter T , and then offset such that they are between 0.5 and 1: w ( s, a )
= σ ( − ˆ Q std ( s ′ , a ′ ) ∗ T ) + 0 . 5 .
The uncertainty of the target is estimated by sampled ensembles.
While SUNRISE proposes other contributions such as an exploration bonus, the heuristic weighting scheme and the limitations of sampled ensembles in capturing the predictive uncertainty leave space for improvement in the mitigation of the effects of unreliable supervision.
We propose inverse-variance reinforcement learning (IV-RL).
IV-RL also uses weights to reduce the importance of uncertain targets in training.
It does so by addressing the problem from two viewpoints.
First, we use variance networks (Kendall & Gal, 2017), whose loss function for regression is the negative log-likelihood instead of the L2 distance.
For a given state-action pair ( s, a ) , the network learns the target’s noise, due for example to the stochasticity of the environment or the update of the policy.
It then naturally down-weights the highly noisy samples in the training process.
Second, we use variance ensembles (Lakshminarayanan et al., 2017) to estimate the uncertainty of the target due to the prediction of Q ( s ′ , a ′ ) during the temporal-difference update.
We merge the predicted variances of several variance networks through a mixture of Gaussians, which has been shown to be a reliable method to capture predictive uncertainty (Ovadia et al., 2019).
We then use Batch Inverse-Variance (BIV) (Mai et al., 2021), which has been shown to significantly improve the performance of supervised learning with neural networks in the case of heteroscedastic regression.
BIV is normalized, which makes it ideal to cope with different and time-varying scales of variance.
We show analytically that these two different variance predictions for the target are complementary and their combination leads to consistent and significant improvements in the sample efficiency and overall performance of the learning process.
In summary, our contribution is threefold:
We present a systematic analysis of the sources of uncertainty in the supervision of modelfree DRL algorithms.
We show that the variance of the supervision noise can be estimated with two complementary methods: negative log-likelihood and variance ensembles.
We introduce IV-RL, a framework that accounts for the uncertainty of the supervisory signal by weighting the samples in a mini-batch during the agent’s training.
IV-RL uses BIV, a weighting scheme that is robust to poorly calibrated variance estimation.3.
Our experiments show that IV-RL can lead to significant improvements in sample efficiency when applied to Deep Q-Networks (DQN) (Mnih et al., 2013) and Soft-Actor Critic (SAC) (Haarnoja et al., 2018).
In section 2, we introduce BIV as a weighting scheme for heteroscedastic regression, and variance ensembles as an uncertainty estimation method.
We analyse the sources of uncertainty in the target in section 3, where we also introduce our IV-RL framework.
We finally present our experimental results in section 4.
B ACKGROUND AND PRELIMINARIES 2. B ATCH I NVERSE -V ARIANCE W EIGHTING
In supervised learning with deep neural networks, it is assumed that the training dataset consists of inputs x k and labels y k .
However, depending on the label generation process, the label may be noisy.
In regression, we can model the noise as a normal distribution around the true label:
˜
y k = y k
+ δ k with δ k ∼ N (0 , σ 2 k ) .
In some cases, the label generation process leads to different variances for the label noises.
When these variances can be estimated, each sample is a triplet (cid:0) x k , ˜ y k , σ 2 k (cid:1) .
Batch Inverse-Variance (BIV) weighting (Mai et al., 2021) leverages the additional information σ 2 k , which is assumed to be provided, to learn faster and obtain better performance in the case of heteroscedastic noise on the labels.
Applied to L2 loss, it optimizes the neural network parameters θ using the following loss function for a mini-batch D of size K 2 :
[Equation]
This is a normalized weighted sum with weights w k
=
( σ 2 k + ξ ) .
Normalizing in the mini-batch enables control of the effective learning rate, especially in cases where the training data changes over time, such as in DRL.
By focusing on the relative scale of the variances instead of their absolute value, it also provides robustness to poor scale-calibration of the variance estimates.
As explained in Mai et al.
(2021), ξ is a hyperparameter that is important for the stability of the optimization process.
A higher ξ limits the highest weights, thus preventing very small variance samples from dominating the loss function for a mini-batch.
However, by controlling the discrimination between the samples, ξ is also key when the variance estimation is not completely trusted.
It provides control of the effective mini-batch size EBS , according to:
[Equation]
For example, imagine a mini-batch where most samples have very high variances, and only one has a very low variance.
If ξ = 0 , this one low-variance sample is effectively the only one to count in the mini-batch, and EBS tends towards 1.
Increasing ξ would give more relative importance to the other samples, thus increasing EBS .
With a very high ξ compared to the variances, all weights are equal, and EBS tends towards K ; in this case, the BIV loss tends towards L 2 .
Tuning the ξ parameter The simplest way to set ξ is to choose a constant value as an additional hyperparameter.
However, the best value is difficult to evaluate a priori and can change when the profile of variances changes during a task, as is the case in DRL.
It is instead possible to numerically compute the value of ξ which ensures a minimal EBS for each mini-batch.
This method allows ξ to automatically adapt to the different scales of variance while ensuring a minimal amount of information from the dataset is accounted for by the algorithm.
The minimal EBS is also a hyper-parameter, but it is easier to set and to transfer among environments, as it is simply a fraction of the original batch size.
As such, it can be set as a batch size ratio.
2. E STIMATING THE UNCERTAINTY OF A NEURAL NETWORK PREDICTION
The predictive uncertainty of a neural network can be considered as the combination of aleatoric and epistemic uncertainties Kendall & Gal (2017).
Aleatoric uncertainty is irreducible and characterizes the non-deterministic relationship between the input and the desired output.
Epistemic uncertainty is instead related to the trained model: it depends on the information available in the training data, the model’s capacity to retain it, and the learning algorithm (H¨ullermeier & Waegeman, 2021).
There is currently no principled way to quantify the amount of task-related information present in the input, the training data, or the model.
The state of the art for predictive uncertainty estimation instead relies on different sorts of proxies.
These sometimes capture other elements, such as the noise of the labels, which we can use to our advantage.
We focus here on the relevant methods to our work.
2.2. S AMPLED ENSEMBLES
Several networks independently train an ensemble of size N that can be interpreted as a distribution over predictions.
The expected behaviour is that different networks will only make similar predictions if they were sufficiently trained for a given input.
The sampled variance of the networks’ outputs is thus interpreted as epistemic uncertainty.
It is possible to include a random Bernoulli mask of probability p to each training sample, to ensure that each network undergoes different training.
This method, used by Clements et al.
and (Lee et al., 2021), has the same principle as single network Monte-Carlo dropout (Gal & Ghahramani, 2016).
As the variance is sampled, the standard deviation is usually on the same scale as the prediction.
When used at the very beginning of the training process, sampled ensembles present one particular challenge: as the networks are initialized, they all predict small values.
The initial variance, instead of capturing the lack of knowledge, is then underestimated.
To address this problem, Randomized
Prior Functions (RPFs) enforce a prior in the variance by pairing each network with a fixed, untrained network which adds its predictions to the output (Osband et al., 2019).
RPFs ensure a high variance at regions of the input space which are not well explored, and a lower variance when the trained networks have learned to compensate for their respective prior and converge to the same output.
The scale of the prior is a hyper-parameter.
2.2. V ARIANCE NETWORKS
With variance networks, the uncertainty is predicted using loss attenuation (Nix & Weigend, 1994;
Kendall & Gal, 2017).
A network outputs two values in its final layer given an input x : the predicted mean µ ( x ) and variance σ 2 ( x ) .
Over a minibatch D of size K , the network parameters θ are optimized by minimizing the negative log-likelihood of a heteroscedastic Gaussian distribution: [Equation]
[Equation]
Variance networks naturally down-weight the labels with high variance in the optimization process.
The variance prediction is trained from the error between µ θ ( x ) and y ( x ) .
Hence, noise on the labels or changes in the regression task over time will also be captured by loss attenuation.
As the variance is predicted by a neural network, it may not be well-calibrated and may be overestimated (Kuleshov et al., 2018;
Levi et al., 2020; Bhatt et al., 2021).
This can (1) give wrong variance estimates but also (2) affect the learning process by ignoring a sample if the variance estimate is too high.
2.2. V ARIANCE ENSEMBLES
Variance ensembles, or deep ensembles (Lakshminarayanan et al., 2017), are ensembles composed of variance networks.
The predictive variance is given by a Gaussian mixture over the variance predictions of each network in the ensemble.
This method, when trained, is able to capture uncertainty more reliably than others (Ovadia et al., 2019), with N = 5 networks in the ensemble being sufficient.
Similarly to sampled ensembles, variance ensembles suffer from underestimated early epistemic variance estimation.
However, compared to variance networks, they seem empirically less prone to calibration issues (1) in the final variance estimation because the mixture of Gaussians dampens single very high variances, and (2) in the learning process because even if one network does not learn correctly, the others will.
For better readability, we will use the terms var-network and var-ensemble in the rest of the paper.
2. U NCERTAINTY AND EXPLORATION IN DRL
While our work focuses on using uncertainty estimates to mitigate the impact of unreliable supervision, we can take advantage of the structure in place to better drive the exploration/exploitation trade-off.
In particular, we used BootstrapDQN (Osband et al., 2016) for exploration.
In this method, a single network is sampled from an ensemble at the beginning of each episode to select the action.
This method is improved with the previously described RPFs (Osband et al., 2018).
In continuous settings, we instead followed Lee et al.
and added an Upper Confidence Bound (UCB) exploration bonus based on uncertainty prediction.
As the variance in UCB is added to Q -values, it must be calibrated: we evaluate it with sampled ensembles.
Possible interactions between exploration strategies and IV-RL are discussed in Appendix H. the exploration due to a significant initial bias added to the value of each state-action.
It must be compensated for with uncertainty-aware exploration, such as Bootstrap (Osband et al., 2016), where it leads to a significant improvement in performance for exploration-based tasks.
I NVERSE -V ARIANCE R EINFORCEMENT L EARNING 3. T ARGET UNCERTAINTY IN R EINFORCEMENT L EARNING
Many model-free DRL algorithms use temporal difference updates.
In methods such as DQN (Mnih et al., 2013), PPO (Schulman et al., 2017) and SAC (Haarnoja et al., 2018), a neural network is trained to predict the Q -value of a given state-action pair Q π ( s, a ) 4 by minimizing the error between the target T ( s, a ) and its prediction ˆ Q ( s, a ) .
T ( s, a ) is computed according to Bellman’s equation:
[Equation]
s ′ and r are sampled from the environment given ( s, a ) , and a ′ is sampled from the current policy given s ′ .
¯ Q ( s ′ , a ′ ) is predicted by a copy of the Q -network (called the target network) which is updated less frequently to ensure training stability.
The neural network’s parameters θ are optimized using stochastic gradient descent to minimize the following L 2 loss function:
[Equation]
3.1. T HE TARGET AS A RANDOM VARIABLE
The target T ( s, a ) is a noisy approximation of Q π ( s, a ) that is distributed according to its distribution p T ( T | s, a ) .
The generative model used to produce samples of
T ( s, a ) is shown in
Figure 1, and has the following components:
if the reward r is stochastic, it is sampled from p R
( r | s, a ) 5 ; 2.
if the environment dynamics are stochastic, the next state s ′ is sampled from p S ′
( s ′ | s, a ) ; 3.
if the policy is stochastic a ′ is sampled from the policy π ( a ′ | s ′ ) ; 4.
¯ Q is a prediction from a var-network p ¯ Q ( ¯ Q
| s ′ , a ′ ) ; 5.
T is deterministically generated from r and ¯ Q by equation (4).
As the variance of the noise of T ( s, a ) is not constant, training the Qnetwork using L θ as in equation (5) is regression on heteroscedastic noisy labels.
3.1. V ARIANCE OF THE TARGET
As seen in section 2.1, BIV can be used to reduce the impact of heteroscedastic noisy labels in regression, provided estimates of the label variances.
We thus aim to evaluate σ 2 T ( T | s, a ) based on the sampling process described in section 3.1.1.
r and Q -value estimation are independent given s and a , hence:
[Equation]
(6) where p S ′
A ′ ¯ Q is the compound probability distribution based on components 2-4 in Figure 1:
[Equation]
(7) where p S ′
A ′ ( s ′ , a ′ | s, a ) =
p A ′ ( a ′ | s ′ )
p S ′
( s ′ | s, a ) .
Using the law of total variance, the variance of ¯ Q is given by:
[Equation]
Plugging (8) into (6) gives:
[Equation]
[Figure]
[Equation] [Equation]
Stochastic reward can happen for example if the reward is corrupted or estimated (Romoff et al., 2018; Campbell et al., 2015)
We can identify two distinct components in equation 9 that contribute to the overall variance of the target.
The first is the (expectation of the) variance that is due to the uncertainty in the neural network prediction of the value function, E S ′
A ′
σ 2¯ Q (cid:0) ¯ Q | s ′ , a ′ (cid:1) ] .
The second is the uncertainty due to the stochasticity of the environment and of the policy, σ 2 R ( r | s, a ) + γ 2 σ 2 S ′
A ′ (cid:0) E ¯ Q (cid:2) ¯ Q
| s ′ , a ′ (cid:3)(cid:1) .
Uncertainty in neural network prediction
For a given policy π and a given s ′ , a ′ , the agent may not have seen enough samples to have an accurate approximation of Q π ( s ′ , a ′ ) .
This corresponds to an epistemic source of uncertainty that should be captured by sampled ensembles.
However, as π is updated, the regression target, Q π ( s ′ , a ′ ) , is also changing.
This can be interpreted as variability in the underlying process which will be captured by var-networks.
We can thus combine both sampling-based and var-network methods and evaluate σ 2¯ Q (cid:0) ¯ Q ( s ′ , a ′ ) (cid:1) with var-ensembles.
We assume that the estimate of σ 2¯ Q ( ¯ Q | s ′ , a ′ ) given a sampled ( s ′ , a ′ ) is unbiased and can therefore use it to directly approximate the expectation E S ′
A ′
σ 2¯ Q (cid:0) ¯ Q | s ′ , a ′ (cid:1) ] .
These values are used in the
BIV loss L BIV (equation 1) across a mini-batch sampled from the replay buffer.
In this case, ξ is used to control the trust in the variance estimation, as explained in section 2.1.
Stochastic environment and policy The other potential source of variance in the target is the result of the stochasticity of the environment encapsulated by p R ( r | s, a ) and p S ′ ( s ′ | s, a ) and of the policy represented by π ( a ′ | s ′ ) .
Note that in model-free RL, we have no explicit representation of p R ( r | s, a ) or p S ′ ( s ′ | s, a ) , which are necessary to estimate this source of uncertainty.
Q π ( s, a ) is defined as the expected value of the return.
As a result, even in the case where where ¯
Q ( s ′ , a ′ ) =
Q π ( s, a ) in (4), there is still noise over the value of the target that is being used as the label due to the stochasticity of the environment and policy that generate r , a ′ and s ′ .
Assuming a zero mean and normally distributed noise, this underlying stochasticity of the generating process is well-captured by a var-network with a loss attenuation using the negative log-likelihood formulation described in equation 3.
3.1. L OSS FUNCTION FOR IV-RL
Based on the motivation above, we propose our IV-RL loss over minibatch D of size K as a linear combination of L BIV and L LA , balanced by hyperparameter λ :
[Equation]
The var-network with parameters θ predicts both µ ˆ Q θ ( s k , a k ) and
σ 2ˆ Q θ ( s k , a k ) for each element k of the mini-batch.
σ 2¯ Q,k is instead provided by the target var-ensemble which predicts ¯ Q ( s ′ k , a ′ k ) when estimating the target T ( s k , a k ) .
In L BIV of equation (1), σ 2 k is replaced by γ 2 σ 2¯ Q,k
according to equation (9).
Empirically, the value of λ is usually optimal around 5 or 10.
Its impact is studied more in details in appendix C. High-variance samples generated from the target estimation will be downweighted in the BIV loss, while high-variance samples due to the stochasticity of the underlying environment and policy will be down-weighted in the LA loss.
In the remainder of the paper, we show how this loss can be applied to different architectures and algorithms, and demonstrate that in many cases it significantly improves sample efficiency.
3. Q- VALUE UNCERTAINTY AND ACTOR - CRITIC STRUCTURES
In section 3.1, we discussed how the target’s uncertainty can be quantified and how the Bellman update can then be interpreted as a heteroscedastic regression problem.
This is applicable in most model-free DRL algorithms, whether they are based on Q -learning or policy optimization.
In the special case of actor-critic algorithms, the state-values or Q -values predicted by the critic network are also used to train the policy π ϕ ’s parameters by gradient ascent optimization.
An estimate of their variance can also be used to improve the learning process.
The objective is to maximize the expected Q-value:
[Equation]
where D is the state distribution over the probable agent trajectories.
The expectation is computed by sampling a mini-batch of size K from a replay buffer containing state-action pairs ( s k , a k ) .
The
Q -value is approximated by the critic as ˆ Q ( s k , a k ) .
The actor’s parameters ϕ are then trained to maximize the unweighted average:
[Equation]
If we instead consider the critic’s estimation ˆ Q ( s k , a k ) as a random variable sampled from p ˆ Q ( ˆ Q | s, a ) , with mean µ ˆ Q ( s k , a k ) and variance σ 2ˆ Q ( s k , a k ) , we can instead infer the expected value in equation (11) using Bayesian estimation (Murphy, 2012):
[Equation]
The normalized inverse-variance weights are a direct fit with the BIV loss in equation 1: we therefore also use BIV to train the actor.
As the target and the Q -networks have the same structure, σ 2ˆ Q ( s k , a k ) can be estimated using the same var-ensembles used in section 3.1.2.
3. A LGORITHMS
We have adapted IV-RL to DQN and SAC to produce IV-DQN and IV-SAC.
Comprehensive pseudocode, as well as implementation details for each algorithm, can be found in appendix A.
R ESULTS
We have tested IV-RL across a variety of different environments, using IV-DQN for discrete tasks and IV-SAC for continuous tasks.
To determine the effects of IV-RL, we compare its performance to the original DQN and SAC, but also the ensemble-based baselines upon which IV-DQN and IV-SAC were built: BootstrapDQN and EnsembleSAC.
We also include SUNRISE (Lee et al., 2021).
All ensemble-based methods use an ensemble size of N = 5 .
Unless specified otherwise, each result is the average of runs over 25 seeds: 5 for the environment × 5 for network initialization.
The hyperparameters are the result of a thorough fine-tuning process explained in appendix B. As it uses ensembles, IV-RL is computationally expensive: computation time is discussed in Appendix D.
4. IV-DQN
We tested IV-DQN on discrete control environments selected to present different characteristics.
From OpenAI Gym (Brockman et al., 2016), LunarLander is a sparse reward control environment and MountainCar is a sparse reward exploration environment.
From BSuite 6 (Osband et al., 2020),
Cartpole-Noise is a dense reward control environment.
The BootstrapDQN baseline follows Osband et al.
(2018) as explained in section 2.3.
The reported SUNRISE results are obtained by applying the
SUNRISE weights to BootstrapDQN.
The learning curves are shown in figure 2, where the results are averaged on a 100 episode window.
IV-DQN significantly outperforms BootstrapDQN and SunriseDQN on control-based environments.
However, in the exploration-based Mountain-Car where the challenge is to find the state that produces some reward, there is very little additional information in every other state for IV-DQN to improve over BootstrapDQN.
All weighting schemes thus perform comparably.
Table 1 shows the median number of episodes necessary to reach a given score for which the environment is considered as solved.
IV-DQN shows a clear improvement over baselines in sample efficiency in both control-based environments but fails to improve the exploration in Mountain Car.
[Table]
In Figure 3 we perform an ablation study for LunarLander and Cartpole-Noise.
In L2 + VarEnsembleDQN
[Table]
the loss function L BIV in equation 10 is replaced by the L 2 loss.
In BIV + BootstrapDQN, sampled ensembles are used instead of var-ensembles
[Table]
and trained only with L BIV .
More details about these ablations are found in appendix A.
In both cases, the use of BIV or var-ensembles improves the performance
[Table]
and their combination leads to the best sample efficiency.
In CartpoleNoise, var-ensembles carry most of the improvement, maybe because the low amount of states leads to low epistemic uncertainty.
We also show that using one single var-network as opposed to var-ensembles is sub-optimal.
This is likely due to the unstable nature of the single uncertainty estimate, which affects the learning process.
More details are shown in appendix E and G.
The use of var-ensembles stabilizes the variance estimation, as explained in section 2.2.3.
4. IV-SAC
IV-SAC was applied to different continuous control environments from OpenAI Gym (Brockman et al., 2016) as implemented by MBBL (Wang et al., 2019).
EnsembleSAC is a baseline using ensembles with an UCB exploration bonus (Lee et al., 2021).
Table 2 shows the average return after 100k and 200k steps on 25 seeds.
We note that the addition of an ensemble instead of a single network, along with the uncertainty-based exploration bonus, already allows the performance to increase compared to SAC.
Except in Ant, the SUNRISE weights do not seem to lead to consistently better results.
In comparison, IV-SAC leads to significant improvements in performance.
This improvement in performance after a fixed amount of training steps can be explained by an improved sample efficiency.
This can be seen in figure 4.
Even when IV-SAC’s return is not signifi-
[Table]
Similarly to IV-DQN, we can separate the contribution from BIV and loss attenuation, as shown in the two first plots of figure 5.
While both BIV and var-ensembles alone have a significant impact in Walker, it’s only their combination that brings the most improvement in HalfCheetah.
Similarly to the discrete control case, a simple var-network leads to a small improvement over SAC, which is discussed in appendix G. We also show in figure 5 that the BIV weights provided with var-ensemble variance estimations than the SUNRISE weights, or even the inverse variance weights of UWAC (Wu et al., 2021).
The normalization of BIV allows it to better cope with changes in the variance predictions, as seem in appendices E and F.
C ONCLUSION
We present Inverse Variance Reinforcement Learning (IV-RL), a framework for model-free deep reinforcement learning which leverages uncertainty estimation to enhance sample efficiency and performance.
A thorough analysis of the sources of noise that contribute to errors in the target motivates the use of a combination of Batch Inverse Variance (BIV) weighting and variance ensembles to estimate the variance of the target and down weight the uncertain samples in two complementary ways.
Our results show that these two components are beneficial and that their combination significantly improves the state of the art in terms of learning efficiency, in particular for control tasks.
We applied IV-RL to DQN and SAC, but it can be adapted to any model-free algorithm.
Modelbased, active or continuous learning could also benefit from the underlying ideas presented in this paper.
We thus believe that IV-RL is a significant step to enable the application of DRL to real-world problems such as robotics, where sample efficiency is the main challenge.
E THICS STATEMENT
In this work, we present a method to enhance the sample efficiency of deep reinforcement learning algorithms.
As such, it is agnostic to the applications, and per se does not raise any particular ethical issue.
We however strongly encourage the user of our algorithm to ensure they have carefully thought about the ethical issues related to the particular field of application, such as medicine, robotics, communication, finance, etc.
As environmental sustainability can also be considered an ethical issue (Universit´e de Montr´eal, 2018), we publish the carbon footprint of our work.
Experiments were conducted using a private infrastructure, which has a carbon efficiency of 0.
kgCO 2 eq/kWh.
A cumulative of 12367 days, or 296808 hours, of computation was mainly performed on the hardware of type RTX 8000 (TDP of 260W).
We assume full power usage of the GPUs, although this was not always the case.
Total emissions are estimated to be 2160.76 kgCO 2 eq of which 0 percents were directly offset.
This is equivalent to 8730 km driven by an average car, or 1.08 metric tons of burned coal.
Estimations were conducted using the MachineLearning Impact calculator presented in Lacoste et al.
R EPRODUCIBILITY STATEMENT
To allow reproducibility of our results, the code, as well as the hyperparameters used to produce each result presented in this paper, are available at https://github.com/montrealrobotics/ iv_rl .
The environments and implementation we used (OpenAI Gym, BSuite, MBBL) are all publicly accessible, although a Mujoco license is needed to run some of them. A CKNOWLEDGEMENTS
The authors wish to thank the DEEL project CRDPJ 537462-18 funded by the National Science and
Engineering Research Council of Canada (NSERC) and the Consortium for Research and Innovation in Aerospace in Qu´ebec (CRIAQ).
They also acknowledge the support of NSERC as well as the
Canadian Institute for Advanced Research (CIFAR).
A A LGORITHMS IN DETAILS
In this section, we are detailing the different algorithms described in the paper, and explaining the design choices that we made.
A. B OOTSTRAP DQN
BootstrapDQN (Osband et al., 2016), improved with Randomized Prior Function (RPF)
(Osband et al., 2018), is an ensemble-based modification of DQN (Mnih et al., 2013).
Instead of a Q - and a target network, we use a Q -ensemble and a target ensemble.
It is the base algorithm upon which
IV-DQN is built.
The detailed steps at training and testing are presented in algorithms 1 and ??
Network architecture The Q -ensemble and the target ensemble are initialized identically with
N = 5 neural networks.
We used multi-layer perceptrons with 2 ReLU-activated hidden layers of 64 nodes.
TD update Following the implementation of Osband et al.
, the networks are paired one to one between the Q - and the target networks during the TD update.
The system can be considered as several DQNs working in parallel.
At training time, the best action a ′ for each Q -network is selected based on the corresponding target network.
Exploration During exploration at training time, one network of the ensemble is used to predict the best action for a whole episode.
This follows Osband et al.
(2016), and is an approximation of
Thompson sampling (Thompson, 1933).
We added random prior functions (Osband et al., 2018) to tackle the variance underestimation at early training.
At test time, the best action a ′ is instead selected by a vote from the networks in the ensembles.
Ties are broken randomly.
Using the mean value across the ensemble was also tested, with slightly lower performances.
Masked replay buffer To mask the replay buffer, each step saved in the replay buffer is associated with a N -sized boolean vector m which is used as a mask during training.
Each element of m indicates if the corresponding network in the Q -ensemble should be trained using this sample.
These elements of m are independently generated when the sample is saved, using a Bernoulli distribution with probability p m .
They are kept fixed during the training.
The role of the mask is to ensure variability in the training of the different networks of the Q -ensemble and thus maintain a significant variance prediction.
1: Input: RPF scale δ RPF , minibatch size K , mask probability p m , ensemble of N Q -networks
Q , ensemble of N target-networks T , ensemble of N prior-networks P 2: for each episode do 3:
Pick a Q -network from Q using i ∼ Uniform (1 ..N )
▷ (Osband et al., 2016) 4: for each time step do 5: a ←− arg max α ( Q i ( s, α )
+ δ RPF P
i
( s, α ))
▷ Random prior (Osband et al., 2018) 6:
Collect next-state s ′ and reward r from the environment by taking action a 7:
Sample bootstrap mask M = m l ∼ { Bernoulli( p m )
| l ∈ 1 , ..., N } 8:
Add ( s, a, s ′ , r, M ) in buffer B 9: s ←− s ′ 10:
Sample minibatch D from replay buffer B 11: for j in [1 . . .
N ] do ▷ Each member of the ensemble 12: for each tuple ( s k , a k , s ′ k , r k , M k ) in minibatch D do ▷ Computing the targets 13: ˆ Q k ←− Q j ( a k , s k ) + δ RPF P j
( s k , a k ))
▷ Expected Q -value 14: a ′ k ←− arg max a ( T j ( s ′ k , a ) + δ RPF P j ( s ′ k , a )) 15:
T k ←− r k + γ ( T j ( s ′ k , a ′ k ) + δ RPF P j ( s ′ k , a ′ k ))
▷ Target 16: end for 17:
Mask minibatch D using M j 18:
Update Q j ’s parameters θ j by minimizing L 2 loss: ( ˆ Q − T ) 2 over D 19:
Soft update of the T j ’s parameters ¯ θ j ←− (1 − τ )¯ θ j + τθ j 20: end for 21: end for 22: end for
A. IV-DQN
IV-DQN is built upon BootstrapDQN.
The main differences are the use of var-networks in the ensemble, the computation of the variance in the TD update, and the use of L IVRL when training the networks’ parameters commonly used to represent epistemic uncertainty in ML.
The pseudo-code for IV-DQN is given in algorithm 2, where the differences with BootstrapDQN are highlighted.
At test time, action selection for IV-DQN is same as BootstrapDQN.
Var-networks architecture Similar to BootstrapDQN, we used ensembles consisting of N =networks.
The var-networks were also multi-layer perceptrons with 2 ReLU-activated hidden layers of 64 nodes.
The only difference is that, instead of a single head for a given ( s, a ) , these networks now provide 2 heads to predict the mean µ θ and the variance σ 2 θ of the Q -value.
To differentiate these outputs of network N given a state-action pair ( s, a ) , we write N µ ( s,
Computing the uncertainty of ¯ Q ( s ′ , a ′ )
As justified in section 3, variance σ 2¯ Q ( s ′ ,a ′ ) is estimated using var-ensembles.
For each ( s ′ k , a ′ k ) pair used to train a single Q -network Q j in ensemble Q , the value of ¯ Q ( s ′ k , a ′ k ) is the mean µ k,j predicted by the corresponding target-network T j .
However, to evaluate σ 2¯ Q , every target-network T l in the target ensemble predicts a mean µ k,l and a variance σ 2 k,l for ¯ Q ( s ′ k , a ′ k ) .
Then, σ 2¯ Q,k ( s ′ k , a ′ k ) is computed as the variance of the mixture of Gaussians composed of all the µ k,l and σ 2 k,l :
[Equation]
where µ 2 k, all is the average of all µ 2 k,l ’s.
Using L IVRL
Given σ 2¯ Q , each network can now learn to predict mean µ and variance σ 2 during the
TD update using L IVRL instead of L 2 .
To select the value of ξ , we specify a minimal effective batch size MEBS .
We use equation (2) to determine if, for the values of σ 2¯ Q,k and ξ = 0 , the effective batch size EBS is lower than MEBS .
If this is the case, ξ is increased until EBS ≥ MEBS using a Nelder Mead optimization method (Nelder & Mead, 1965).
Uniform (1 ..N )
▷ (Osband et al., 2016) 4: for each time step do 5: a
[Equation]
arg max
[Equation]
( Q
[Equation]
( s,
[Equation]
[Equation]
RPF P i ( s, α ))
▷ Random prior (Osband et al., 2018) 6:
Collect next-state s ′ and reward r from the environment by taking action a 7:
Sample bootstrap mask M = m l ∼ { Bernoulli( p m )
| l ∈ 1 , ..., N } 8:
Add ( s, a, s ′ , r, M ) in buffer B 9: s ←− s ′ 10:
Sample minibatch D from replay buffer B 11: for j in [1 . . .
N ] do 12: for each tuple ( s k , a k , s ′ k , r k , M k ) in mini-batch D do 13: µ [Equation]
[Equation]
▷ Expected Q -value 14: a
[Equation]
max
[Equation]
P
[Equation]
s [Equation]
a )) 15:
T
[Equation]
[Equation]
▷ Target 16: for l in [1 . . .
N ] do ▷ µ and σ 2 for each network of the ensemble 17: µ
[Equation]
) 18: σ
[Equation]
) 19: end for 20:
[Equation]
▷ Average of the mean predictions 21:
[Equation]
▷ Variance of mixture of Gaussians 22: end for 23:
Estimate ξ based on all σ 2¯ Q,k so that EBS ≥ MEBS using Eq.
Mask minibatch using M j 25:
Train Q j ’s parameters θ j with L IVRL (10) using µ ˆ Q , T , ξ and σ 2¯ Q on D 26:
Soft update of T j ’s parameters ¯ θ j ←− (1 − τ )¯ θ j + τθ j 27: end for 28: end for 29: end for
A. A BLATIONS FOR IV-DQN
In the ablation study presented in section 4.1, 4 new algorithms are presented.
We detail here their differences with IV-DQN and algorithm 2.
BIV + BootstrapDQN In BIV + BootstrapDQN, the networks used in the ensembles are singlehead networks, similar to BootstrapDQN.
Thus, these are sampled ensembles.
σ 2¯ Q,k is thus computed as the sampled variance of the networks’ predictions.
Additionally, instead of L IVRL , we simply use
L BIV .
Compared to algorithm 2, lines 1 to 17 are the same.
Line 18 is removed.
Line 21 is changed by: σ 2¯ Q,k ←− 1 /N (cid:80) Nl =1 ( µ ¯ Q,l − µ ¯ Q, all ) 2 .
Finally, in line 25, L IVRL is changed to L BIV .
L2 + VarEnsembleDQN
In L2 + VarEnsembleDQN, we do not apply BIV weights.
The difference with IV-DQN is that we simply change L BIV for the L 2 loss in L IVRL .
The networks are still var-networks trained with the L LA part of the L IVRL loss, and the rest of the algorithm is the same as algorithm 2.
In practice, the computation of σ 2¯ Q,k and ξ are now useless, and lines 16 to 21 as well as line 23 can be removed.
BIV + VarNetworkDQN In BIV + VarNetworkDQN, we use a single var-network instead of a var-ensemble.
Concretely, N = 1 .
This means that at line 21, σ 2¯ Q,k is effectively the variance output by the single target network.
Additionally, masks and RPF do not make sense here, so they are not applied.
As the BootstrapDQN exploration cannot apply either, an ϵ -greedy strategy is used instead.
L2 + VarNetworkDQN L2 + VarNetworkDQN is BIV + VarNetworkDQN, without BIV weights.
L BIV is replaced by the L 2 loss in L IVRL .
A. IV-SAC
IV-SAC is built upon EnsembleSAC, which is inspired by SUNRISE (Lee et al., 2021).
We describe here the main elements of IV-SAC, and present the detailed process in algorithm 3.
The variance networks used in IV-SAC are multilayer perceptrons with flattened inputs and 2 ReLU-activated hidden layers of 256 nodes.
Our implementation is based on rlkit 8 .
Critic SAC is a complex DRL algorithm with several details which are orthogonal to IV-RL, for example, the accounting of policy entropy in the definition of the Q -value.
On the critic side, the implementation of IV-RL is mostly similar to IV-DQN’s TD update.
Actor
Following the example of Lee et al.
(2021), we use an ensemble for the actor-network when using ensembles for the critic.
Each network in the actor is linked to a pair of networks in the critic.
When training, the Q -value and its variance for each state-action are computed similarly as when training the critic.
As justified in section 3.2, we also apply the BIV loss function when training the actor.
However, instead of the L 2 error shown in equation (1), we use the SAC loss function for the actor.
For a minibatch D of size K , we have:
[Equation]
Action selection The use of an ensemble for the d allows for different methods to select the next action given a state.
In this respect, we follow again the example of Lee et al.
During the training of the Q-network, we pair each Q-network with its corresponding actor.
To encourage exploration, we additionally take advantage of the ensemble to implement UCB.
Each policy network outputs an action.
The mean Q -value µ Q ( s, a ) and variance σ 2 Q ( s, a ) for each action a are computed by sampling over all networks of the critic.
The chosen action has the highest UCB score: a ∗ = arg max a [ µ Q ( s, a ) + Λ UCB σ Q ( s, a )] , where Λ UCB is a hyperparameter.
To estimate the standard deviation for UCB, we use sampled ensembles: this is because, for UCB, the variance estimation must be calibrated, in order to be correctly scaled with the Q -values.
Varensembles are therefore disqualified.
During testing, the agent takes the average action, as sampled from the output of the mean prediction by the policy networks.
1: Input: LA weight λ , UCB Λ UCB , minimal effective batch size MEBS , policy networks π , ensemble of N Q -var-networks Q , ensemble of N target-var-networks T 2: for each episode do 3: for each time step do 4:
Collect the action samples: A ←− { a i ∼ π i ( a | s ) | i ∈ { 1 , ..., N }} 5: a ←− arg max a i ∈A [ µ ( Q ( s, a i ))
+ Λ UCB σ ( Q ( s, a i ))]
▷ UCB exploration 6:
Collect next-state s ′ and reward r from the environment by taking action a 7:
Sample bootstrap mask M ←− { m l ∼ Bernoulli( p m ) | l ∈ { 1 , ..., N }} 8:
Store tuple ( s, a, s ′ , r, M ) in buffer B 9: s ←− s ′ 10: end for 11: for each optimization step do 12:
Sample minibatch D from the replay buffer B 13: for j in [1 . . .
N ] do ▷ Each member of the ensemble 14: for each tuple ( s k , a k , s ′ k , r k , M k ) in minibatch D do ▷ Computing the targets 15:
Sample next-action: a ′ k,j ∼ π j ( a ′ | s ′ k ) 16:
Compute Expected Q-value: µ ˆ Q,k ←− Q µj ( a k , s k ) 17:
Compute Target:
T k ←− r k + γ T µj ( s ′ k , a ′ k,j ) 18: σ 2ˆ Q,k ←− Predictive-Variance( Q , s k , a k,j ) ▷ Algorithm19: σ 2¯ Q,k ←− Predictive-Variance( T , s ′ k , a ′ k,j ) ▷ Algorithm20: end for 21:
Mask minibatch D using M j 22:
Estimate ξ a
so that EBS ( σ 2ˆ Q ) ≥ MEBS using Eq.
Update π j ’s parameters ϕ j with L actor (15) using µ ˆ Q , π j , ξ a and σ 2ˆ Q 24:
Estimate ξ c so that EBS ( σ 2¯ Q ) ≥ MEBS using Eq.
Update Q j ’s parameters θ j with L IVRL (10) using µ ˆ Q , T , ξ c and σ 2¯ Q on D 26:
Soft update of T j ’s parameters ¯ θ j ←− (1 − τ )¯ θ j + τθ j 27: end for 28: end for 29: end for
1: procedure P REDICTIVE -V ARIANCE ( N , s, a ) 2:
Input: Var-networks ensemble: N , State: s , Action: a 3: for l in { 1 ...N } do 4: µ l ←− N µl ( s, a ) 5: σ 2 l ←− N σ 2 l ( s, a ) 6: end for 7: µ N ←− 1 /N (cid:80)
Nl =1 µ l ▷ Average of predictions 8: σ 2 N ←− 1 /N (cid:80)
Nl =1 σ 2 l + µ 2 l − µ 2 N ▷ Variance of mixture of Gaussians 9: return σ 2 N 10: end procedure
A. A BLATIONS FOR IV-SAC
We also do ablation studies with our IV-SAC model (presented in section 4.2) where we showadditional variations.
We detail here their differences with IV-SAC with respect to algorithm 3.
EnsembleSAC EnsembleSAC is the base on which IV-SAC is built.
It uses regular networks as critics instead of variance networks in the ensemble, and it does not consider uncertainty.
Compared to algorithm 4, lines 1 to 17, and 20, 21, 26 to 29 are identical.
Lines 18, 19, 22 and 24 are removed. In line 23 and 25, the usual losses of SAC are used instead of L actor and L BIV .
BIV+EnsembleSAC Similar to EnsembleSAC, this version uses regular networks as critic instead of variance networks in the ensemble.
However, it is uncertainty aware: it estimates the variance of the prediction using sampled ensembles.
It is thus similar to SunriseSAC (Lee et al., 2021), but with
BIV weights instead of SUNRISE weights.
σ 2¯ Q,k and σ 2ˆ Q,k being computed as the sampled variance of the networks’ predictions, we change these lines compared to algorithm 3:
• line 18 to: σ 2ˆ Q,k ←− 1 /N (cid:80) N l =1 ( µ ˆ Q,l − 1 /N (cid:80) N m = 1 µ ˆ Q,m )• line 19 to: σ 2¯ Q,k ←− 1 /N (cid:80)
Nl =1 ( µ ¯ Q,l − 1 /N (cid:80) Nm =1 µ ¯ Q,m )
Additionally, instead of L IVRL , we use L BIV for the critic at line 25.
L2 + VarEnsembleSAC
Here, we do not apply BIV weights to both actor and critic losses.
The critic networks are still var-networks trained with the L LA part of the L IVRL loss, and the rest of the algorithm is the same as algorithm 3.
In practice, the computation of σ 2¯ Q,k and ξ are now useless, and lines 18, 19, 22 and 24 can be removed.
BIV + VarNetworkSAC We use a single var-network instead of a var-ensemble as the critic.
Concretely, N = 1 .
This means that at lines 18 and 19, σ 2ˆ Q,k and σ 2¯ Q,k are effectively the variance output by the single-target network.
L2 + VarNetworksAC VarNetwork is BIV + VarNetwork, without BIV weights in both actor and critic losses.
L BIV is replaced by the L 2 loss in L IVRL .
UWAC + VarEnsemble
Here we change the weighing scheme in IV-SAC to the one proposed in
Wu et al.
(2021), keeping everything else the same.
Sunrise + VarEnsemble
For this version we modify the weighing scheme in IV-SAC to the one proposed in Lee et al.
(2021), keeping everything else the same.
B H YPERPARAMETER TUNING
Deep reinforcement learning algorithms are known to be particularly difficult to evaluate due to the high stochasticity of the learning process and the dependence on hyperparameters.
To thoroughly compare different algorithms, it is important to carefully tune the hyperparameters, based on several environments and network initialization seeds (Henderson et al., 2018).
For every result presented in this paper, the hyperparameters for each algorithm were tuned using grid search.
Each combination of hyperparameters was run five times, with different seeds on both initialization and environment.
The best 3 or 4 configurations were then selected to be run 25 times - this time, the combinations of 5 environment and 5 initialization seeds.
The configuration selected to be shown in the paper is the best of these configurations based on the 25 runs.
Table 3 describes the type and sets of parameters that were optimized for the relevant algorithms.
Note that the learning rate lr , discount rate γ and target new update rate τ are also relevant for
SAC.
Because there was too many hyperparameters to tune, we kept for all SAC experiments the [Table] SUNRISE temperature [Table]
[Table] [Table] [Table] [Table]
[Table]
[Table]
[Table] in Wu et al [Table] [Table]
The hyperparameters used for each curve can be found in the configuration file of the code submitted as additional material.
C λ IN L IVRL
As expressed in equation (10), the L IVRL loss function we use to train the Q -value estimation is a combination of two components, L BIV and L LA , balanced by hyperparameter λ .
We use Adam (Kingma & Ba, 2015) optimizer: any constant multiplied to the loss function is absorbed and does not impact the gradient.
Therefore, λ effectively controls the ratio between L BIV and L LA .
The sensitivity to the value of λ depends on the scale of the return, the stochasticity of the environment, and the learning dynamics.
As can be seen in figure 6, changing the values of λ between 1 and 10 lead to different results in LunarLander, HalfCheetah and Ant, while in SlimHumanoid, Walker and Hopper, the performance stays very similar.
In figure 7, we analyze how the performance of IV-RL methods change when λ is set to extreme values.
Very high values of λ lead to sub-optimal results, first because L BIV is practically ignored, but also because using variance ensembles alone may lead to a slower or less stable learning curve.
Very low values of λ , on the other hand, also bring the performance down, first as L LA is ignored, but also as the variance prediction is not trained: the uncertainty estimates provided to L BIV are less reliable.
From figure 7, we can see that the effect of λ depends on the environment.
For LunarLander, smaller λ leads to slower learning and sub-optimal performance in comparison to λ = 10 .
On the other hand, very high λ leads to poor performance and never reach the goal score of 200.
For SlimHumanoid, both extremes show inferior performance to when λ = 10 , but, although there are differences in the dynamics, they reach similar a score after 200k steps.
In Walker, high λ is also slower, however, the impact of low λ is less important.
This can be attributed to the fact that, for Walker, the BIV component contributes more to performance than the LA component of IV-RL loss, as seen in figure 5.
D C OMPUTATION TIME
As IV-RL uses ensembles, the computation time necessary for the training of the agents is significantly increased compared to single-network algorithms such as SAC or DQN.
This can be seen in tables 4 and 5.
The computation of ξ for MEBS as well as additional forward passes to evaluate the variance add some computational load compared to other ensemble-based methods such as BootstrapDQN and
SunriseDQN.
While this can limit the applicability of IV-RL, we consider the cases where computation time is secondary to sample efficiency.
This is the case when samples are the more expensive element, such as in the real world.
[Table] [Table]
E V ARIANCE ESTIMATION
The difference of performance between IV-RL with sampled ensembles and variance ensembles is sometimes significant.
Looking at the variance prediction can allow us to better understand this result.
E. IV-DQN
In figure 8, we show the mean of the sample variance estimations per mini-batch, depending on the variance estimation method.
Different profiles can be seen in LunarLander and Cartpole-Noise.
In the first environment, the scale of the variance predicted by sampled ensembles with BootstrapDQN and variance ensembles does not differ significantly.
In Cartpole-Noise however, the variance ensembles quickly capture much more uncertainty.
This explains the difference in dynamics that can be seen in Figure 3.
Although we do not have results for single variance networks in Cartpole-Noise, we can see in
LunarLander why single variance networks are less reliable than variance ensembles.
The mean variance they predict is very high, but, as can be seen in Figure 9, the median is a lot lower.
The mean is thus driven by extremely high variance predictions.
Instead, sampled and variance ensembles show similar profiles for mean and median variance.
The low median variance confirms that single variance networks fail to capture epistemic uncertainty, but also that they have very high volatility.
E. IV-SAC
In the continuous control environments, the story is different, as can be seen in Figures 10 and 11.
The first thing to notice is the volatility of the mean of the variance produced by variance ensembles.
Although the scale is not completely unreasonable and is still close to the median, (on the opposite of variance networks in DQN), it still suffers from some calibration issues.
Second, we see that the epistemic variance in EnsembleSAC is higher than the one in BIV + EnsembleSAC.
One hypothesis to explain this is that using IV reduces the impact of very noisy supervision which may confuse the networks and increase the variance in the ensemble.
Variance ensembles do not seem to suffer from this.
F W EIGHTING SCHEMES
The study on the variance allows a better understanding of the advantage of the BIV weights (Mai et al., 2021) compared to the UWAC weights (Wu et al., 2021) and SUNRISE weights (Lee et al., 2021).
In these works, the weight w k of a sample k in a minibatch of size K is given by:
[Equation]
Figure 12 shows the result of applying such weights to variance ensembles.
Note that the first two plots are repeated from figure 5 in section 4.2.
It is clear that the SUNRISE weights, which are based on a heuristic, are not optimal compared to the more theoretically grounded UWAC and BIV weights.
However, we can note that UWAC weights perform much better than SUNRISE, but are still somewhat inferior to BIV weights.
Our understanding is that this is due to the changes in the scale of the variance estimation along the learning process, as seen in figures 8 and 10.
In UWAC, this first leads to continuous changes in the effective learning rate.
For example, multiplying the variances by 2 divides the weights accordingly by 2.
While the multiplication of the loss by a constant is captured by optimizers such as Adam (Kingma & Ba, 2015) in the long term, it can still cause short term disturbances in the learning process.
In comparison, the normalization of the
BIV weights ensures the stability of the loss function.
UWAC weights are also hard-clipped by the value 1.5, after being scaled by a constant hyperparameter β .
When the scale of the variances changes, this can disturb the control over the discriminatory power of the weights.
For example, if all variances are smaller than β , all weights are clipped and become identical at 1.5, and the weighting scheme does not discriminate between certain and uncertain samples.
On the other hand, if most variances are very high compared to β , the weights will be very low.
A single low-variance sample may thus completely outweigh all other samples, which will get ignored in the gradient update.
The discrimination is then too strong.
BIV instead uses ξ , which is dynamically computed to maintain a minimal effective batch size MEBS as explained in section 2.1.
The relative weights of the samples are thus preserved if the variances are multiplied by a constant.
As such, the BIV weights maintain a stable discriminatory power in the face of changing variance scales along the learning process, leading to better results.
Note that the curves here present the combination of UWAC and SUNRISE with var-ensembles, which is different from the original works proposed by Wu et al.
(2021) (using MC-Dropout) and
Lee et al.
(2021) (using sampled ensembles).
G V ARIANCE NETWORKS
What if, instead of using predictive ensembles, we simply replaced the Q -network by a variance network and trained it using the IV-RL loss?
Figure 13 shows the performances on 4 continuous environments, compared to SAC.
We can see a slight improvement, but it is not statistically significant.
Based on the insights given in section E, we make the hypothesis that it is due to the volatility of the variance estimation with a single variance network.
H IV-RL AND O PTIMISM IN THE F ACE OF U NCERTAINTY
A question that arose during this research is how does IV-RL interact with the principle of Optimism in the Face of Uncertainty (OFU), which is often used to drive exploration in reinforcement learning, for example with Upper Confidence Bounds (UCB).
The principle behind IV-RL is to down-weight highly uncertain samples during the TD-update; the idea of OFU is to encourage the agent to choose actions with high uncertainty during exploration.
Do these two approach go against each other?
First, we would like to distinguish the uncertainty of the value estimation at state-action pair Q ( s, a ) used by OFU, and the uncertainty of the value estimation of the target T ( s, a ) used by IV-RL.
They are separate: we tell the agent to go where the Q ( s, a ) is uncertain, and then to sample a target
T ( s, a ) by projecting over the next time step with Q ( s ′ , a ′ ) .
T ( s, a ) has its own uncertainty, which is not that of Q ( s, a ) .
If the agent believes T ( s, a ) is highly uncertain, it should not give it too much weight.
T ( s, a ) may also have low uncertainty: the agent will then give it more importance.
However, two factors come and blur this distinction.
First, in the context of reinforcement learning where the experience is built with trajectories, the information the agent has received at ( s ′ , a ′ ) is correlated to the information it received at ( s, a ) .
Second, the use of function approximation may cause the uncertainty of Q ( s, a ) and the uncertainty of Q ( s ′ , a ′ ) to be similar, especially if ( s, a ) is close to ( s ′ , a ′ ) on the state-action space.
These correlations may induce interactions between
IV-RL and OFU, which may not be completely decoupled.
Another element needs to be considered: in both IV-DQN and IV-SAC, exploration is made following the Q -networks, whereas the value of Q ( s ′ , a ′ ) to compute the target is estimated by target networks, which are delayed compared to Q -networks.
This reduces the correlations between the uncertainties of Q ( s, a ) and T ( s, a ) .
As an empirical element to this answer, we show in the paper that OFU and IV-RL work together: the IV-SAC experiments include a UCB bonus for exploration.
It is to be noted that, if these two strategies can conflict, IV-RL proposes the use of hyperparameter MEBS which allows us to control the intensity of its discrimination.
By increasing the MEBS , one can give more importance to highvariance samples, and find an optimal balance.
Nevertheless, we believe this question is important for all strategies based on weighting samples according to variance in DRL and could be an interesting line of future investigation.