Bayesian Q-learning With Imperfect Expert Demonstrations
Abstract
Guided exploration with expert demonstrations improves data efficiency for reinforcement learning, but current algorithms often overuse expert information.
We propose a novel algorithm to speed up Q-learning with the help of a limited amount of imperfect expert demonstrations.
The algorithm avoids excessive reliance on expert data by relaxing the optimal expert assumption and gradually reducing the usage of uninformative expert data according to the uncertainty of learning results.
Experimentally, we evaluate our approach on a sparse-reward chain environment and six more complicated Atari games with delayed rewards.
With the proposed methods, we can achieve better results than Deep Q-learning from Demonstrations (Hester et al., 2017) in most environments.
Introduction
Reinforcement learning (RL) trains an agent to maximize expected cumulative rewards through online interactions with an environment [Sutton and Barto, 2018].
To speed up learning, online RL can be combined with offline expert demonstrations [Hester et al., 2018], which guides the agent toward high-rewarding behaviours and thus improves data efficiency.
Most existing expert demonstration methods [Brys et al., 2015, Abbeel and Ng, 2004] either clone behaviours from the expert or bonus expert actions.
However, agents are provided with imperfect expert data and gain distracting guidance.
Some works start handling the imperfect expert data but still lack solid theoretical foundation [Nair et al., 2018, Zhang et al., 2022].
Our paper adopts Bayesian frameworks [Ghavamzadeh et al., 2015, Dearden et al., 1998], which provide an analytical method to incorporate extra sub-optimal expert information for learning.
In the probabilistic model for Bayesian inference, the sub-optimal expert decision is assumed to rely on the Boltzmann distribution dependent on the optimal expected returns from state-action pairs, called the optimal Q-values.
Intuitively, our paper considers that the expert would prefer actions with higher optimal Q-values.
Based on this relationship, the agent can infer values of the optimal Q-values from the given expert data during online learning and correct estimated Q-values to better correspond to the expert behaviours.
This inference is equivalent to maximizing the posterior distribution of Q-values conditioned on expert data, but computing the maximum of a posterior probability is a difficult task [Hoffman et al., 2013, Diaconis and Ylvisaker, 1979, West et al., 1985].
Therefore, our paper proposes to utilize the generalized extended Kalman filter (GEKF) [Fahrmeir, 1992] to derive a posterior maximum, requiring fewer restrictions on Q-values functions than other Bayesian RL frameworks [Dearden et al., 1998, Engel et al., 2003, Osband et al., 2019].
Under the assumptions from the GEKF framework, we derive an iterative forward way to compute
Q-values, which consists of a Q-value-update step as in the Q-learning algorithm and an expert correction step.
In the correction step, our update rule weighs expert information according to an agent’s uncertainty of its self-learning result, measured by the estimated posterior variance of learned Q-values.
Thus, the larger Q-values’ variance is, the more our expert correction encourages expert behaviours by increasing expert actions’ Q-values and decreasing non-experts’ Q-values.
This mechanism reduces the influence of uninformative expert data and avoids excessive guided exploration.
Furthermore, we propose our computationally efficient deep algorithm, Bayesian Q-learning from
Demonstrations (BQfD), built on top of the Deep Q-learning Network (DQN) [Mnih et al., 2013].
The algorithm embeds reliable expert knowledge into Q-values and leads to a more efficient exploration, as shown on a sparse-reward chain environment DeepSea and six randomly chosen Atari games.
In most environments, our algorithm learns faster than Deep Q-learning from Demonstrations (DQfD)
[Hester et al., 2018] and Prioritized Double Duelling (PDD) DQN [Wang et al., 2016].
Related Work
Reinforcement learning from demonstrations (RLfD) has drawn attention in recent years.
This method only requires a small number of offline expert demonstrations and can noticeably improve performance.
Deep Q-learning from demonstrations (DQfD)
[Hester et al., 2018] includes an additional margin classification loss to ensure that Q -values of expert actions are higher than other actions.
Reinforcement learning from demonstrations through shaping [Brys et al., 2015] assigns high potential to a state-action pair ( s, a ) when the action a is used by the expert in the neighbourhood of the state s .
Wu et al.
[Wu et al., 2020] further leverages reward potential computed by generative models.
However, this requires an added complexity of training generative models.
Expert data is also used implicitly to learn rewards inversely at the beginning [Abbeel and Ng, 2004, Brown et al., 2019].
However, these approaches do not consider the case where the expert is imperfect and can often have difficulty exceeding expert performance.
In contrast, Nair et al.
[Nair et al., 2018] handle suboptimal demonstrations by only cloning expert actions when their current estimated Q-values are higher than others.
Zhang et al.
[Zhang et al., 2022] utilizes expert information when the cumulative Q-values on expert state-action pairs are larger than cumulative value functions.
However, the learned Q-value is often unreliable and frequently changes, making it a poor judgment of expert data quality.
At the same time, our measurement based on the posterior variance of estimated Q-values is more reasonable.
Jing et al.
[Jing et al., 2020] models the suboptimal expert policy as a local optimum to maximize the expected returns and then constrains the agent to learn within a region around the expert policy, measured by KL divergence between occupancy measures.
However, the local optimum condition is hard to satisfy, and the limitation of learning around the expert policy cannot deal with mistaken expert actions.
In contrast, our assumption on Boltzmann distributed expert policy is much weaker.
Background
A Markov decision process [Sutton and Barto, 2018] is a tuple M = ⟨S , A , P, γ, R, ρ ⟩ where S is the state space, A is the action space, P is the time-homogeneous transition probability matrix with P ( s ′ | s, a ) as elements, γ ∈ (0 , 1) is the discount factor, R is the reward function, with R ( s, a ) denoting a random vector describing rewards received after state-action pair ( s, a ) and ρ is the distribution of the initial state.
At each time step h , the agent samples an action A h from a policy µ , and then transits to the next state S h +1 and gains a reward R ( S h , A h ) .
Our paper focuses on finite horizon cases with horizon H , where an agent stops at time step H .
Also, our paper works on finite action and state spaces.
The expected discounted cumulative return starting from each state-action pair ( s, a ) at time step h and following the policy µ is called the Q-value, denoted by q µh ( s, a ) , and is defined as follows:
[Equation]
) = E τ [ H (cid:88) t = h γ t R ( S t , A t )] , where τ denotes trajectories with S h
= s ,
A h
= a , S t ∼ P ( ·| S t − 1 , A t − 1 ) ,
A t ∼ µ ( ·| S h ) and rewards R ( S t , A t ) .
The unique optimal Q-value function at time h is defined as:
[Equation] The optimal Q-values also satisfy the optimal Bellman equation for all states and actions:
[Equation]
The optimal Bellman operator T is defined by the equation.
Moreover, the optimal Q-values at each time h for all state-action pairs can be combined into one vector, q ∗ h ∈ R |S|×|A| , each element representing the optimal Q-value for a state-action pair.
Optimal Q-values can be computed by Q-learning [Watkins and Dayan, 1992, Jin et al., 2018], which estimates Q-values directly and is based on the following update rule:
[Equation]
where Q is an estimation of Q-values, S ′ ∼ P ( ·| s, a ) is a sampled next state, and α ∈ (0 , 1) is the learning rate.
A choice of adaptive learning rate is to assign each state-action pair a learning rate and decay it with respect to the number of visitations to the state-action pair.
We use n l ( s, a ) to represent the number of visitation times of state-action pair ( s, a ) until and including episode l .
Bayesian reinforcement learning assumes that there is an initial guess or a prior probability over the model parameters, denoted by P ( M ) .
Then in the model-based case, the agent gradually learns a posterior probability for the model parameters conditioned on observed trajectories [Duff, 2003].
Next, an agent can learn a policy based on the most likely MDP or by sampling MDPs from the posterior.
In the model-free case, we treat Q-values as random variables and implicitly embed parametric uncertainties from different MDPs.
A prior distribution of the optimal Q-values at time h is defined as:
[Equation]
Then algorithms compute the posterior probability of Q-values [Dearden et al., 1998, Osband et al., 2018].
Model
In this section, we present the probabilistic model used for Bayesian inference and then derive the update rule of Q-values by maximizing posterior probability.
4.1 Probabilistic Model of Suboptimal Expert Actions
We start by modeling the relationship between expert actions and the optimal Q-values.
The expert chooses the optimal actions most frequently but may contain mistakes and select low probability actions.
The Boltzmann distribution can describe this behavior with the optimal Q-values as parameters.
Under this distribution, expert actions are sampled proportional to the exponential of optimal
Q-values up to a constant multiplier.
As known, this assumed expert policy maximizes the expected returns regularized by the entropy [Haarnoja et al., 2018], describing almost optimal but sometimes mistaken expert behaviors.
The above assumption is formally presented as follows and shown on the left of figure 1, where the expert action at time h and state s is denoted by A exp,h (s).
Assumption 1.
Assume that expert demonstrations are drawn from a policy π expert dependent on the optimal Q-values.
Also, this policy follows the Boltzmann distribution:
[Equation]
where η is any positive constant.
Moreover, we capture the relationship between the optimal Q-values at different time steps in our probabilistic model through the Bellman equation 1.
However, the Bellman equation cannot be computed without the knowledge of environment dynamics. Therefore, our model relies on samples of the reward and the next state, which are widely accepted in the field [Watkins and Dayan, 1992].
We re-write the Bellman equation in a stochastic form as
[Equation]
where R ( s, a ) and the next state S ′ are sampled according to the rules of the underlying MDP.
The random noise ν is defined as [Equation] which captures the randomness from the dynamics.
Then, the whole model of relationships among rewards, optimal Q-values, and expert actions along a trajectory is presented on the right of figure 1.
4.2 GEKF Framework
Next, our desired estimated Q-values should not only follow the stochastic Bellman equation, but they should also most likely give the Boltzmann distribution that the expert is following.
This objective is equivalent to maximizing the posterior probabilities of optimal Q-values equaling our estimations conditioned on expert information while constraining to the stochastic Bellman equation. In order to compute the posterior probability, we need help from a framework under which the posterior probability density function or the posterior mode is of analytical form. Thus, our paper leverages the generalized extended Kalman filter (GEKF) [Fahrmeir, 1992], which can analyze the time series of Q-values with extra expert information and provides an estimation of the posterior maximum.
This framework requires extra expert information following an exponential family distribution, which is already assumed.
Furthermore, the framework requires the random noise ν in the stochastic Bellman equation 3 at each
Q-value update step to be Gaussian, which is also assumed in Osband et al. [Osband et al., 2019].
Meanwhile, this assumption does not hurt in the latter stage of training since the influence of the random noise gradually approaches zero as the number of samples increases, and the learning rate decays.
Notice that the random noise should have a zero expectation and bounded variance when rewards and time horizons are bounded.
Thus, our paper considers ν as a Gaussian random variable with zero expectation and a fixed variance λ , as shown in the following assumption.
Assumption 2.
For all state-action pair ( s, a ) ,the noise ν is modeled independently by a Gaussian random variable ν ∼ N (0 , λ ) .
Also, the GEKF framework approximates the posterior distribution by Gaussian and treats the maximization operator in Q-value updates linearly as in Osband et al. [Osband et al., 2019].
4.3 Derivation of Q-values Update Rules
We derive our Q-value estimations Q under the above assumptions given by the GEKF framework [Fahrmeir, 1992].
Firstly, this estimation should satisfy the stochastic Bellman equation in equation 3.
Secondly, it should maximize the posterior probability of the optimal Q-values conditioned on expert demonstrations.
This task is stated as follows:
[Equation]
Recall that q ∗ h ∈ R |S||A| represents the Q-value vector at step h with each element as the value of one state-action pair, and similar for R h ; moreover, A exp,h ∈ R |S| represents the expert actions chosen at all states at step h .
Then, we can eliminate terms independent of Q-values in the posterior and obtain:
[Equation]
where the three distributions are modeled through our previous assumptions: the expert action follows a Boltzmann distribution, Q-values at step h follow a Gaussian distribution with the expectation given by the Bellman equation, and Q-values at step H are all set to be zero.
Next, the task in equation 4 forms a constrained optimization problem and can further be transformed into a two-point boundary value problem [Fahrmeir, 1992, Sage and Melsa, 1971]. This boundary value problem is then solved by the invariant embedding method, which provides approximate solutions for non-linear partial differential equations. The derivation is shown in the appendix following the steps in Sage (1997) [Sage and Melsa, 1971].
Finally, in a backward view, our estimations can be computed step-by-step as presented in algorithm 1.
In the prediction step, the algorithm updates Q-values based on sampled rewards and sampled next states by the Bellman equation as the Q-learning algorithm
[Watkins and Dayan, 1992].
This update of estimated Q-values can be written as
[Equation]
using a transformation matrix T ∈ R |S||A|×|S||A| .
Its element at each state-action pair and its next-state-maximal-action pair equals to one, that is T [( s, a ) , ( S ′ , a ′ )]
= 1 where S ′ ∼ P ( ·| s, a ) and a ′ =
argmax b Q h {++
+} ( S ′ , b ) .
And all other elements are zero.
Then, the algorithm computes the estimated posterior variance W .
Our derivation gives that this variance not only depends on the transformation matrix T , but also the Hessian of log expert policy
U ∈ R |S||A|×|S||A| .
After computing the variance, expert information corrects Q-values as
[Equation]
Recall that η is the parameter of the expert policy.
So a bonus weighted by the variance is given to expert actions and encourages the agent to explore them when it is not confident of the current learning result.
When the variance of a Q-value estimate is low, the agent stops guided exploration by the expert and follows its own learnt policy.
Thus, the agent can deal with inadequate expert data by gradually ignoring it.
Meanwhile, this expert modification does not break the stochastic Bellman equation in equation 3 since it is listed as the constraint in the posterior maximization task in equation
Algorithm
Our paper proposes an algorithm Bayesian Q-learning from Demonstrations (BQfD) to realize the
GEKF update rules of Q-values as shown in algorithm 1. This algorithm samples a trajectory at
Initialize: Q-values at the last step Q H = 0 , Weight matrices of Q-value functions W H = 0 |S||A|×|S||A| , and Identity matrix I .
for time step h
= H − 1 , ..., 0 do
Prediction step:
Update Q-value of each state-action pair based on sampled reward and next state though Bellman equation [Equation] Correction step: Compute the estimated posterior variance
[Equation]
Embed in the expert correction [Equation] end for the beginning of each turn and then updates Q-values by the sampled-based Bellman rule and the expert correction backward. Thus, our algorithm only updates the Q-value of the state-action pair ( S h , A h ) at each time step h and introduces a learning rate α for Bellman equation updates to reduce variances.
This learning rate α n ( s,a ) ( s, a ) is considered to be state-action pair dependent and decays as the number of that pair’s visitations n ( s, a ) increases.
However, the posterior variance calculation in the correction step is computationally inefficient due to the Hessian and inverse operations. To avoid these computations, we would like to approximate the posterior variance at a state-action pair ( s, a ) .
Given a first-order decaying learning rate α n ( s,a ) ( s, a ) = 1 β + n ( s,a ) , short written as α and ignoring the variance change by expert information, the variance is roughly a function of the visitation times, denoted by w n ( s,a ) =
O ( 1 ( n ( s,a ) λ ) and it is similar to count-based exploration [Bellemare et al., 2016].
Furthermore, our paper utilizes deep neural networks and proposes a deep BQfD based on Prioritized
Dueling Double (PDD) Deep Q-learning Network (DQN) [Mnih et al., 2013, Wang et al., 2016, Hessel et al., 2018].
Notice that our current update rule requires expert information for every state, while a limited set of expert demonstrations is usually provided.
Meanwhile, the indicator value in the expert correction may have conflict values if an expert provides multiple trajectories but chooses different actions at a state.
Instead, our algorithm suggests storing expert data in the replay buffer and only performing expert correction when sampling expert data from the buffer. Also, our algorithm weighs expert data to reduce off-policy biases.
The importance sampling ratio is hard to calculate, so our algorithm uses a computationally-efficient weight [Equation] where the power ζ is a rescaling factor to avoid miniature weights. This ratio assigns higher values to more frequent state-action pairs under the current ϵ -greedy policy with respect to Q-estimates.
The detailed algorithm is presented in algorithm 3 in the appendix.  Experiment To evaluate the discernment of expert data, we test our algorithm using optimal and misleading expert data in a sparse-reward chain environment called DeepSea [Osband et al., 2019].
Then, we further test the data efficiency of our algorithm with the help of a limited amount of suboptimal human data on six complicated Atari games [Brockman et al., 2016].
We compare against other two discrete-action algorithms:
Prioritized Dueling Double (PDD)
Deep Q-learning Network (DQN) [Mnih et al., 2013, Wang et al., 2016, Hessel et al., 2018] with EZ-greedy [Dabney et al., 2020] exploration and Deep Q-learning from demonstrations (DQfD).
The DeepSea environment requires less than one hour of training on an Nvidia 2070 GPU. Each Atari game requires 21 days of training on Compute Canada server with either one
DeepSea is a deterministic chain environment of length N with two actions: left and right.
A to describe the environment is shown in the appendix
The agent is initialized on the left in each episode and terminates after N steps.
The agent receives rewards of 0 for left actions and − the right actions except for a fixed but unknown reward at the most right state. The unknown but fixed reward consists of either a treasure with a bonus of +1 or a bomb with a cost of − 1 .
Regardless of the environment, we always provide agents with an expert trajectory towards the most right.
Thus, in the treasure case, we test our algorithms’ efficiency; in the bomb case, we evaluate our algorithms’ robustness in the presence of highly misleading expert information.
To provide a fair comparison, we include an expert trajectory to the replay buffer of DQN and provide no pretraining for any algorithms.
The results for the treasure case are shown on the left of figure 2.
BQfD and DQfD can gain the optimal reward after one training episode much faster than DQN since the expert data directly leads to the reward, and these two algorithms extract expert information efficiently.
But DQfD assumes the expert data to be optimal and causes catastrophic performance when expert demonstrations are misguiding, as seen in the bomb case, shown on the right of figure 2.
On the contrary, our learningfrom-demonstrations approach successfully learns the optimal policy, though the convergence speed is hindered due to confusing information.
This result proves that BQfD efficiently extracts expert information and gradually stops using expert information.
6.2 Arcade Learning Environment Experiment Settings
We further evaluated our approach on Arcade Learning Environments [Brockman et al., 2016, Mnih et al., 2013]: Breakout, ChopperCommand, Freeway, MsPacman, VideoPinball, and Seaquest.
The architecture for all three algorithms is the same as PDD DQN [Mnih et al., 2013, Wang et al., 2016, Hester et al., 2018, Hessel et al., 2018] with prioritized replay buffer [Schaul et al., 2015].
Baselines’ hyperparameters follow the choices in DQfD and prioritized replay buffer.
Meanwhile, we tune hyperparameters for BQfD on the environment Seaquest, and the detailed results are shown in the appendix.
All approaches are provided with one human-generated expert trajectory and are pretrained with this expert data.
Given the randomness during training, all results shown are averaged over three random seeds. [Table]
The overall results are shown in table 1.
Here, we present final-learned evaluation rewards: the average means and standard deviations of evaluation rewards over the last 2M steps.
Our algorithm outperforms the baselines in Breakout, ChopperCommand, Seaquest [Table] and VideoPinball.
In MsPacman, it still performs better than DQN but slightly worse than DQfD.
In general, both three algorithms perform much worse than humans on MsPacman.
DQN dominates the game in Freeway [Table] but our algorithm recovers from weak expert data compared to DQfD
[Table]
The learning curve of Breakout and Freeway are presented in figure 3. Initially, the three algorithms’ performances do not show significant differences. But the average evaluation performance slowly tilts in favor of BQfD; it learns fastest, and the order of DQN and DQfD varies. Surprisingly, BQfD’s advantage arises in the latter stages of training instead of improving learning speed in the early stages.
One reason might be that expert data leads to adequate explorations. Also, our approach encourages the agent to deviate from expert states and learn from trials and errors.  Discussion Learning with demonstrations is an exciting direction for robotics tasks with continuous actions.
Though our approach is limited to discrete action problems, it can be extended to continuous actions and policy gradient algorithms left as future work. Furthermore, a more accurate approximation of posterior variance should be considered for future work. Moreover, when experts are not limited to being optimal but instead generate informative trajectories, the quality of expert demonstrations becomes more challenging to judge. The task of selecting the correct expert becomes an important question.
Appendix Derivation of Generalized Extended Kalman Filters
We derive the Q-value update rules under assumptions from the GEKF framework.
The proof follows the steps in Sage and James (1997) [Sage and Melsa, 1971].
A Kalman filter estimates the hidden Q-values Q h of an agent at each discrete time step t = 0 , ..., T given noisy expert observations A exp,h ,
h = H − 1 , ..., 0 and noisy transition functions.
The Linear
Kalman Filter requires the previous state Q h and observation A exp,h +1 to depend linearly on the current state Q h
+1 .
The extended Kalman filter relaxes these relationships to smooth functions.
In this section, we discuss the generalized extended Kalman filter [Fahrmeir, 1992] where the observation A exp,h +1 follows any exponential family distribution with the current state Q h +1 as parameters.
The probabilistic model is defined as:
[Equation]
The linear and extended Kalman filters assume that the posterior is a Gaussian distribution; thus, they do not need to distinguish between conditional means and posterior modes.
However, these two estimators are not equivalent to the generalized extended Kalman filter.
This paper focuses on the maximum a posteriori estimator for a Kalman filter [Sage and Melsa, 1971].
Due to the Markovian assumptions of the model, the posterior distribution of hidden states is proportional to
[Equation]
Maximizing the posterior is equivalent to minimizing the negative log probability.
By combining this objective with the probabilistic model in Equation 5, when Q H = 0 , we obtain: [Equation] Here
[Equation]
we write the log observation probability as ψ ( Q h ) and define the minimization objective
J ( Q 0: H ) , subject to equations in 5:
[Equation]
This optimization problem can be solved by exploiting Lagrangian multipliers α 0 , ..., α H .
First, the equality constraints are combined into the loss to form a Lagrangian function:
[Equation]
where
[Equation]
Then, a minimal solution requires the gradients of the Lagrangian function over all variables to be zero at that point.
This procedure results in a partial differential equation (PDE) system, also known as a two-point boundary value problem.
For convenience, we denote the partial derivative of the log observation probability as:
[Equation]
Then the PDE is presented as:
[Equation]
For simplicity, the differential equations above can be expressed as
[Equation]
This PDE system can be solved by the invariant embedding method.
Our goal is to learn a function of
Q 0: H − 1 which only depends on constants and the time step h , denoted as
[Equation]
According to this function, Q-values at the previous step h − 1 satisfy that
[Equation]
By plugging in function f and g in equation 7, we obtain
[Equation]
Since those PDEs in equation 6 are all linear of Lagrangian multiplies α 0: H , it is further assumed that the function r ( C, h ) is a linear function of variable C .
Thus r ( C, h ) can be written linearly by r ( C, h ) =
D ( h ) − P ( h ) C where D and P are some smooth functions of step h .
Since r ( C, h ) must satisfy the boundary assumptions Q h
= r ( C, h )
for any C ∈ R , D ( h ) must equal to Q h and thus r ( C, h ) =
Q h − P ( h ) C .
After substituting it into equation 8, we obtain
[Equation]
When deriving Q-value estimations backward, at each time step, we only maximize the posterior probability from this step until termination.
Thus, we work on the boundary of the PDE with
Lagrangian multiplier C =
α = 0 .
Therefore, the above equation holds at C = 0 , and both sides’ derivatives over variable C are also equal.
Thus, we gain the update rule:
[Equation]
The final step is to derive the initial conditions of Q H , P H .
When the trajectory length is zero, we have a simple loss | Q H − 0 | , and obviously, the minimum point is Q H = 0 .
Recall that the invariant embedding assumption gives Q H
= r
( α H , H ) =
Q H − P ( H ) α H and the boundary value allows α H to be any constant.
Therefore, we conclude that P ( H ) = 0 .
Now we have an exact per-step update rule given these initial values.
[Equation]
with initial conditions Q
Algorithm
Input: Expert actions A exp ( s ) for all states, a constant β .
Initialize: Q-value functions Q 00: H = 0 .
for Each episode l=1,2,... do
Sample: Initialize S l 0 and sample a trajectory of length H by choosing A lh with maximum
Q-value.
Observe { R lh } H − 1 h
=
for Each time step h
=H-1,...,0 do
Q-value update
[Equation]
if s h is visited in expert demonstration then
Compute Weight Decay
[Equation]
Expert Correction
[Equation]
end if end for
Initialize: Q-value functions for next episode Q l +1 H
+
=
Q lend for
Algorithm
Based on the GEKF model, our estimations can be computed step-by-step as presented in algorithmin a backward view. The per-step update rule comprises a prediction step, the sample-based Bellman update and a correction step.
Note that W is the posterior covariance term in Kalman filters. Our BQfD algorithm shown in algorithm 2 is to avoid the matrix inversion and Hessian computation in the update of weights W .
We only update the Q-value of the current state-action pair ( s h , a h ) and approximate the weight of { ( s h , a h ) , ( s h , a h ) } by a O ( 1 n l ( s h ,a h ) ) term where n l ( s h , a h ) is the visitation time of this state-action pair until the episode l .
Next, we extend our algorithm and include deep neural networks. We use TD loss for non-expert transitions denoted as J ( theta ) and use en expert-information embedded loss J exp ( θ ) for expert transition, defined as:
[Equation]
where θ target is the parameters of target network, θ main are the parameters of the main network, and a max = argmax a ˜ Q ( s ′ , a ; θ target ) .
We also leverage prioritized replay buffer [Schaul et al., 2015] to balance the amount of expert data and online training data. The detailed algorithm is presented in algorithm 3.
Experiment Setting
The DeepSea environment requires less than one hour of training on an Nvidia 2070 GPU.
Each Atari game requires 21 days of training on Compute Canada server with only 1 GPU and 24GB memory.
The GPU on Compute Canada is either Nvidia V100 or Nvidia P100.
All codes are provided in the supplementary material.
DeepSea
As shown in figure 4, DeepSea is a deterministic chain environment represented as a square grid of size N × N .
All agents are initialized at the top-left corner.
At each time step, the agent can move left or right but always moves down by one.
Notice that the edges of the grid bound the agent’s Algorithm
Initialize: D replay : initialized with demonstration data set, θ main : random weights for main network (random), θ target : random weights for target network (random), τ : target network update frequency Pretrain: Randomly sample from replay buffer and minimize loss J exp ( θ ) for step t=1,2,... do Take action a at state s with maximum current Q-values ˜ Q ( s, a ; θ main ) Play action a and observe ( s ′ , r )
Store ( s, a, r, s ′ , terminal ) into prioritized replay buffer D replay
Sample a mini-batch from D replay according to prioritization if data is from expert then
Minimize J exp ( θ main ) and perform a gradient descent step to θ main end if if data is newly drawn then
Minimize J ( θ main ) and perform a gradient descent step to θ main end
if if t mod τ =0 then
Update θ target by θ main end if end for movements.
Each game terminates whenever the agent reaches the bottom.
The agent receives rewards of 0 for left actions and − 0 .
01 N for the right actions except for a fixed but unknown reward at the bottom-right state.
The unknown reward consists of either a treasure with a bonus of +1 or a bomb with a cost of − 1 .
DeepSea suffers from both sparse rewards and small negative rewards for movements towards the unknown reward.
Thus, it is a suitable environment to test the efficiency of guided exploration.
The architecture consists of two layers of Perceptron with Relu activation functions.
It is followed by two dense layers with 256 hidden units that output value function and advantage function. The
[Table] [Table] state is the current position denote by a 2-dimensional vector.
The hyperparameters of BQfD are set as follows: learning rate lr = 0 .
0005 , variance λ = 0 .
6 , and expert policy parameter η = 3 .
The learning rate for other methods is tuned to be lr = 0 .
Detailed tuning results on game of grid
N = 20 are shown in table 2.
Atari
We further evaluated our approach on Arcade Learning Environments: Breakout, ChopperCommand,
Freeway, MsPacman, VideoPinball, and Seaquest.
The architecture for all three algorithms is the same as PDD DQN; it consists of three layers of convolution neural networks of filter sizes 32, 64, and 64, kernel sizes [8, 8], [4, 4], and [3, 3], and strides of 4, 2, 1 respectively where each layer has a
ReLU activation function.
Furthermore, the output is passed to two dense layers, which output the value and advantage functions.
As in DQfD, the input features are grey-scaled Atari frames resized to [84, 84] with a history length of 4.
Furthermore, we scale down the reward during training to allow for standardized learning rates for all games, and each reward r is scaled as sign ( r ) log (1 + r ) .
We reuse hyperparameters from DQfD and prioritized replay buffer for the two baselines.
For
BQfD, we tune our hyperparameters on the environment Seaquest, including learning rate, variance, and expert priority decay ratio.
However, all three algorithms cannot learn the game MsPacman.
So we tune the learning rate and initial random exploration ratio on MsPacman separately.
The hyperparameters are chosen as shown in table 3: learning rate lr = 0 . 000055 and variance λ
= 22 .
The expert priority decay speed is set to 4 , meaning priorities of expert data decay until 4 ×millions of simulation steps.
The initial epsilon greedy exploration ratio is 1 . 0 for MsPacman and 0 . 0 for others.
All approaches are provided with one human-generated expert trajectory and are pretrained with this expert data.
The expert trajectory is generated by a human player who understands the game’s rules but occasionally makes mistakes.
For Breakout, ChopperCommand, Freeway,
MsPacman, Seaquest, and VideoPinball, the expert demonstrations contain a single trajectory of 110, 33800, 27, 30k, 34k, and 82k rewards, respectively.
Furthermore, we ensured that, in total, the expert demonstrations consist of around 6k frames; note for Freeway, we repeated the same trajectory thrice as its maximum length of a single game is 2049.
The training on Atari games requires reloading due to time limits, but the replay buffer is not saved.
The counting of visitation times for BQfD is reset to mean previous visitation times among expert data.
Thus, there may exist a performance downgrade in the middle.