Reinforcement Learning in Feature Space: Matrix Bandit, Kernels, and Regret Bound
Lin F. Yang, Mengdi Wang
Introduction
Reinforcement learning (RL) is about learning to make sequential decisions in an unknown environment through trial and error. It finds wide applications in robotics Kober et al., (2013), autonomous driving Shalev-Shwartz et al., (2016), game AI Silver et al., (2017) and beyond. We consider a basic RL model - the Markov decision process (MDP). In the MDP, an agent at a state is able to play an action , where and are the state and action spaces. Then the system transitions to another state according to an unknown probability , while returning an immediate reward . The goal of the agent is to obtain the maximal possible return after playing for a period of time - even though she has no knowledge about the transition probabilities at the beginning.
The performance of a learning algorithm is measured by “regret”. Regret is the difference between the cumulative reward obtained using the best possible policy and the cumulative reward obtained by the learning algorithm. In the tabular setting where and are finite sets, there exist algorithms that achieve asymptotic regret (e.g. Jaksch et al., (2010); Osband and Van Roy, (2016); Osband et al., (2017); Agrawal and Jia, (2017); Azar et al., (2017); Dann et al., (2018); Jin et al., (2018)), where is the number of time steps. However, the aforementioned regret bound depends polynomially on and , sizes of the state and action space, which can be very large or even infinite. For instance, the game of Go has unique states, and a robotic arm has infinitely many continuous-valued states. In the most general sense, the regret is nonimprovable in the worst case Jaksch et al., (2010). This issue is more generally known as the “curse of dimensionality” of control and dynamic programming Bellman, (1966).
To tackle the dimensionality, a common practice is to use features to parameterize high-dimensional value and policy functions in compact presentations, with the hope that the features can capture leading structures of the MDP. In fact, there are phenomenal empirical successes of reinforcement learning using explicit features and/or neural networks as implicit features (see e.g., Mnih et al., (2015)). However, there is a lack of theoretical understanding about using features for exploration in RL and its learning complexity. In this paper, we are interested in the following theoretical question:
Furthermore, we consider online RL in a reproducing kernel space. Kernel methods are well known to be powerful to capture nonlinearity and high dimensionality in many machine learning tasks Shawe-Taylor et al., (2004). We are interested in using kernel methods to capture nonlinearity in the state-transition dynamics of MDP. A kernel space may consist of infinitely many implicit feature functions. We study the following questions: How to use kernels in online reinforcement learning? Can one achieve low regret even though the kernel space is infinite-dimensional? The goal of this paper is to answer the aforementioned questions affirmatively. In particular, we would like to design algorithms that take advantages of given features and kernels to achieve efficient exploration.
In the kernel setting, this condition is equivalent to that the transition probability model belongs to the product space of the reproducing kernel spaces. This condition is essentially equivalent to using the features to represent value functions Parr et al., (2008). When the probability transition model cannot be fully embedded using , then value function approximation using may lead to arbitrarily large Bellman error Yang and Wang, (2019).
We propose an algorithm, which is referred to as MatrixRL, that actively explores the state-action space by estimating the core matrix via ridge regression. The algorithm balances the exploitation-exploration tradeoff by constructing a confidence ball of core matrix for optimistic dynamic programming. It can be thought of as a “matrix bandit” algorithm which generalizes the idea of linear bandit (e.g. Dani et al., (2008); Li et al., (2010); Chu et al., (2011)). It is proved to achieve the regret bound either
depending on regularity properties of the features. MatrixRL can be implemented efficiently in space . Each step can be carried out in closed form. Next we extend the MatrixRL to work with the kernel spaces with and , and show that it admits a kernelized version. The kernelized MatrixRL achieves a regret bound of
where is the effective dimension of kernel space, even if there may be infinitely many features. The regret bounds using features or kernels do not depend on sizes of the state and action spaces, making efficient exploration possible in high dimensions.
Note that for linear bandit, the regret lower bound is known to be Dani et al., (2008). Since linear bandit is a special case of RL, our regret bounds match the lower bound up to polylog factors in and . To our best knowledge, for reinforcement learning using features/kernels, our result gives the first regret bound that is simultaneously near-optimal in time , polynomial in the planning horizon , and near-optimal in the feature dimension .
2 Related Literature
In the tabular case where there are finitely many states and actions without any structural knowledge, complexity and regret for RL has been extensively studied. For -horizon episodic RL, efficient methods typically achieve regret that scale asymptotically as (see for examples Jaksch et al., (2010); Osband and Van Roy, (2016); Osband et al., (2017); Agrawal and Jia, (2017); Azar et al., (2017); Dann et al., (2018); Jin et al., (2018)). In particular, Jaksch et al., (2010) provided a regret lower bound for -horizon MDP. There is also a line of works studying the sample complexity of obtaining a value or policy that is at most -suboptimal Kakade, (2003); Strehl et al., (2006, 2009); Szita and Szepesvári, (2010); Lattimore and Hutter, (2014); Azar et al., (2013); Dann and Brunskill, (2015); Sidford et al., (2018). The optimal sample complexity for finding an -optimal policy is O\big{(}|\mathcal{S}||\mathcal{A}|(1-\gamma)^{-2}\epsilon^{-2}\big{)} Sidford et al., (2018) for a discounted MDP with discount factor . The optimal lower bound has been proven in Azar et al., (2013).
There is also a line of works on solving MDPs with a function approximation. For instance Baird, (1995); Tsitsiklis and Van Roy, (1997); Parr et al., (2008); Mnih et al., (2013, 2015); Silver et al., (2017); Yang and Wang, (2019). There are also phenomenal empirical successes in deep reinforcement learning as well (e.g., Silver et al., (2017)). However there are not many works on the regret analysis of RL with function approximators. Very recently, Azizzadenesheli et al., (2018) studied the regret bound for linear function approximator. However their bound has factor that can be exponential in . Chowdhury and Gopalan, (2019) considers the regret bound for kernelized MDP. However, they need a Gaussian process prior and assumes that the transition is deterministic with some controllable amount of noise – a very restrictive setting. Another work Modi and Tewari, (2019) also considers the linear setting for RL. However, the regret bound is linearly depending on the number of states. To the best of our knowledge, we are not aware of other works that achieve regret bound for RL with function approximators that is simultaneously near optimal in , polynomial in , and has no dependence with the state-action space size.
Our results are also related to the literature of linear bandits. Bandit problems can be viewed as a special case as Markov decision problems. There is a line of works on linear bandit problems and their regret analysis Dani et al., (2008); Rusmevichientong and Tsitsiklis, (2010); Li et al., (2010); Abbasi-Yadkori et al., (2011); Chu et al., (2011). For a more detailed survey, please refer to Bubeck et al., (2012). Part of our results are inspired by the kernelization for the linear bandit problems, e.g. Valko et al., (2013); Chowdhury and Gopalan, (2017), who studied the regret bound when the features of each arm lies in some reproducing kernel Hilbert space.
Problem Formulation
In a episodic Markov decision process (MDP for short), there is a set of states and a set of actions , which are not necessarily finite. At any state , an agent is allowed to play an action . She receives an immediate reward after playing at , the process will transition to the next state with probability , where is the collection of transition distributions. After time steps, the system restarts at a prespecified state . The full instance of an MDP can be described by the tuple The agent would like to find a policy that maximizes the long-term expected reward starting from every state and every stage , i.e.,
In the online RL setting, the learning algorithm interacts with the environment episodically. Each episode starts from state takes steps to finish. We let denote the current number of episodes and denote the current time step. We equalize and and may switch between the two nations. We use the following definition of regret.
Suppose we run algorithm in the online environment of an MDP for steps. We define the regret for algorithm as
Throughout this paper, we focus on RL problems where the probability transition kernel can be fully embedded in a given feature space.
Here, we call the matrix as a transition core.
Note that when are features associated with two reproducing kernel spaces and , this assumption requires that belong to their product kernel space .
RL Exploration in Feature Space
In this section, we study the near optimal way to balance exploration and exploitation in RL using a given set of features. We aim to develop an online RL algorithm with regret that depends only on the feature size but not on the size of the state-action space. Our algorithm is inspired by the LinUCB algorithm Chu et al., (2011) and its variants Dani et al., (2008) and can be viewed as a “matrix bandit” method.
The high level idea of the algorithm is to approximate the unknown transition core using data that has been collected so far. Suppose at the time step (i.e. episode and stage ), we obtain the following state-action-state transition triplet: where . For simplicity, we denote the associated features by
Let . We construct our estimator of as:
Let us explain the intuition of . Note that
Therefore is the solution to the following ridge regression problem:
Upper confidence RL using a matrix ball.
In online RL, a critical step is to estimate future value of the current state and action use dynamic programming. To better balance exploitation and exploration, we use a matrix ball to construct optimistic value function estimator. At episode :
Here the matrix ball is constructed as
where is a parameter to be determined later, and . At time , suppose the current state is , we play the optimistic action The full algorithm is given in Algorithm 1.
2 Regret Bounds for MatrixRL
Let and be positive parameters.
;
With these conditions we are ready to provide the regret bound.
Suppose Assumption 1 and Assumption 2 hold. Then after steps, Algorithm 1 achieves regret bound:
if we let for some absolute constant .
Further, if the feature space admits a tighter bound for value function in this space, we can slightly modify our algorithm to achieve sharper regret bound. To do this, we need to slightly change our Assumption 2 to Assumption 2′.
Let and be positive parameters.
;
We modify the algorithm slightly by using a Frobenious-norm matrix ball instead of the 2-1 norm and computing sharper confidence bounds. Let in (3.1), where
Then a sharper regret bound can be established.
Suppose Assumption 1 and Assumption 2′ hold. Then after steps, Algorithm 1, with applied in (3.1), achieves regret
provided for some absolute constant .
The only stronger condition needed by Assumption 2′ is . It can be satisfied if is a set of sparse features, or if is a set of highly concentrated features.
We remark that in Theorem 1 and Theorem 2, we need to know the value in before the algorithm runs. In the case when is unknown, one can use the doubling trick to learn adaptively: first we run the algorithm by picking , then for until the true is reached. It is standard knowledge that this trick increase the overall regret by only a constant factor (e.g. Besson and Kaufmann, (2018)).
Proof Sketch. The proof consists of two parts. We show that when the core matrix belongs to the sequence of constructed balls , the estimated Q-functions provide optimistic estimates of the optimal values, therefore the algorithm’s regret can be bounded using the sum of confidence bounds on the sample path. The second part constructs a martingale difference sequence by decomposing a matrix into an iterative sum and uses a probabilistic concentration argument to show that the “good” event happens with sufficiently high probability. Full proofs of Theorems 1 and 2 are deferred to the appendix.
Near optimality of regret bounds. The regret bound in Theorem 2 matches the optimal regret bound for linear bandit Dani et al., (2008). In fact, linear bandit is a special case of RL: the planning horizon is . Therefore our bound is nearly optimal in and .
Implementation. Algorithm 1 can be implemented easily in space . When implementing Step 6 using (3.1), we do not need to compute the entire function as the algorithm only queries the -values at particular encountered state-action pairs. For the computation of , we can apply random sampling over the columns of to accelerate the computation (see e.g. Drineas and Mahoney, (2016) for more details). We can also apply the random sampling method to compute the matrix and approximately.
Closed-form confidence bounds. Equation (3.1) requires maximization over a matrix ball. However, it is not necessary to solve this maximization problem explicitly. The algorithm only requires an optimistic Q value. In fact, we can use a closed-form confidence bound instead of searching for the optimal in the confidence ball. It can be verified that Theorem 1 still holds (by following the same proofs of the theorem) if we replace the second equation of (3.1) as the following equation (see the proof of Theorem 2)
where Similarly, Theorem 2 still holds if we replace the the second equation of 3.1 with
Equations (7) and (8) can be computed easily. They can be viewed as the “dualization” of (3.1).
RL Exploration in Kernel Space
We are now ready to kernelize Algorithm 1. The full algorithm of Kernelized MatrixRL is given in Algorithm 2. Note that the new Q function estimator (6) is the dualization form of (3.1). Therefore Algorithm 2 is more general but essentially equivalent to Algorithm 1 if we let and . See Section B for the proof.
2 Regret Bound for Kernelized MatrixRL
We define the effective dimension of the kernel space as
Further, we need regularity assumptions for the kernel space.
Let be generated by orthonormal basis on , i.e., there exists such that and . There exists a constant such that
where denotes the Hilbert space norm.
The formal guarantee of Kernelized MatrixRL is presented as follows.
Suppose the probability transition kernel belongs to the product Hilbert spaces, i.e., . Let Assumption 3 hold. Then after time steps, the regret of Algorithm 2 satisfies
provided and .
Note that in Assumption 3, we can additionally relax the assumption on the orthogonality of . Similar regret bound can be proved with Assumption 2′. The proof of Theorem 3 is very similar to that of Theorem 2. Although Kernelized MatrixRL does not access the features, the proof is based on the underlying features and the equivalence between kernel representation and feature representation. We postpone it to Section B.
Remark. Similar as MatrixRL, Kernelized MatrixRL can be generalized to deal with unknown reward function by using the Kernelized Bandit Valko et al., (2013). Again, since linear bandit problems are special cases of kernel RL with , our results match the linear bandit bound on and . The computation time of Kernelized MatrixRL scales with time as (by applying randomized algorithms, e.g. Dani et al., (2008), in dealing with matrices), still polynomial in . We can apply the random features or sketching techniques for kernel to additionally accelerate the computation (e.g. Rahimi and Recht, (2008); Yang et al., (2017)).
Summary
This paper provided the algorithm MatrixRL for episodic reinforcement learning in high dimensions. It also provides the first regret bounds that are near-optimal in time and feature dimension and polynomial in the planning horizon . MatrixRL uses given features (or kernels) to estimate a core transition matrix and its confidence ball, which is used to compute optimistic Q-functions for balancing the exploitation-exploration tradeoff. We prove that the regret of MatrixRL is bounded by {O}\big{(}H^{2}d\log T\sqrt{T}\big{)} where is the number of features, provided that the feature space satisfies some regularity conditions. MatrixRL has an equivalent kernel version, which does not require explicit features. The kernelized MatrixRL satisfies a regret bound {O}\big{(}H^{2}\widetilde{d}\log T\sqrt{T}\big{)}, where is the effective dimension of the kernel space. For future work, it remains open if the regularity condition can be relaxed and if there is a more efficient way for constructing confidence balls in order to further reduce the regret.
References
Appendix A Analysis and Proofs
In this section we will focus on proving Theorem 1. In the proof we will also establish all the necessary analytical tools for proving Theorem 2 and Theorem 3. We provide the proofs of the last two theorems at the end of this section.
The proof of Theorem 1 consists of two steps: (a) We first show that if the true transition core is always in the confidence ball , defined in Equation 5, we can then achieve the desired regret bound; (b) We then show that with high probability, the event required by (a) happens. We formalize the event required by step (a) as follows.
For all , we denote if for all and otherwise .
Note that is completely determined by the game history up to episode . In the next section, we show (a).
To better investigate the regret formulation (1), we rewrite it according to Algorithm 1. Note that conditioning on the history before episode , the algorithm plays a fixed policy for episode . Therefore, we have
where . We now show that the algorithm always plays an optimistic action (an action with value estimated greater than the optimal value of the state).
Suppose for , we have the good estimator event, , happens. Then for and , we have
We prove the lemma by induction on . It is vacuously true for the case since . Suppose the lemma holds for some . We then have
We now consider . Note that
Next we show that the confidence ball actually gives a strong upper bound for the estimation error: the estimation error is “along” the direction of the exploration.
Next we show that the value iteration per-step does not introduce too much error.
Suppose for , . Then for , we have
We are now ready to show the regret bound.
Suppose Assumption 2 holds, , then,
Consider for a fixed . Denote as the filtration of fixing the history up to time (i.e., fixing but not ). Since if , we can always bound . We then have
The proof of this lemma is rather technical and requires some new notations, we postpone it to Section A.3. We are now ready to state the regret bound.
Suppose and , then
A.2 Concentration
In this section, we show that holds with high probability through out the online learning process. We begin with some notations and axillary random variables. For , we denote if is lexicographically before , i.e., either or but . For each , we denote
Notice that and . Moreover, we denote
Similar to Lemma 9 of Dani et al., (2008), we have the following lemma.
Firstly, we have . Next, consider . We have
Note that , which proves the first inequality.
Next we consider the second inequality. Since is positive definite (PD), instead of considering the determinant directly, we consider the trace of .
where we use the fact that . Since is PD, for the worst case we have
We also let for all . We consider the following random variables.
If we can bound for all , we can therefore conclude whether is in the ball . To prove the that is indeed small, we use similar techniques developed in Dani et al., (2008). We denote
The next lemma bounds the growth of .
The proof is very similar to Lemma 12 of Dani et al., (2008). For completeness, we present the proof here. We first introduce the following notation.
Let if , or if . We then have
Applying the matrix inversion lemma to , we have
We now define a martingale difference sequence. In order to upper bound the variance of the random variables, we consider
Then is a martingale difference sequence with respect to .
Since determines , , , and (note that in the definition of , variable is not included), we have
We will show that with high probability, the martingale difference sum, never grows too large.
To prove this lemma, we will apply the Freedman’s inequality.
Let be a martingale difference sequence with respect to . Let be an uniform upper bound on . Let be the sum of conditional variances,
We first show the upper bounds on the step size of the martingale .
Next we bound the conditional variance of . We have,
Next by Freedman’s inequality (picking and ), we have,
for some sufficiently large constant such that
Lastly, we show that holds with high probability through out.
We will show that for all given for all , as this proves the lemma. We show this by induction on . For the base case , we have . By inductive hypothesis, for all . By Lemma 11, we have
for some sufficiently large constant . ∎
A.3 Proof of Theorem 1
Before we prove Theorem 1, we first prove the Lemma 8
We will bound the right hand side by establishing an inequality with . Recall that
Notice that each eigenvalue of is at least and
We let . By Lemma 13 and 15, we pick
A.4 Proof of Theorem 2
The proof of Theorem 2 is nearly identical with that of Theorem 1. We will modify Lemma 5 and Lemma 6 to counter for the change of the confidence ball.
For a modification of Lemma 5, we show that for any ,
The rest of the proof follows analogously from that of Theorem 1. ∎
Appendix B Derivation of Kernelization
For the analysis, let us presumably have the features . In the actual algorithm we will avoid using features directly. At time , we denote
Note that and are the feature vectors of the encountered state-action pairs; are the features of all states in . We also overload the notation by denoting and . We then observe
can be represented without knowing the features. Similarly, we do not need features to compute and .
Kernelized Value Estimation
We introduce a dual matrix , and let . Then we have
Therefore, it remains to represent by the kernel matrices.
This completes the kernelization of the prediction.
Kernelized Confidence Bound
Next we write the confidence bound in the kernelized way as well. We represent the same way as in Valko et al., (2013). Note that
from which we solve :
Kernelized Algorithm
We are now ready to write our -function estimator:
where is a parameter to be determined. With (3.1) replaced by (6) in Algorithm 1, we obtain our Kernelized MatrixRL, algorithm Algorithm 2.
B.1 Proof of Theorem 3
To prove the theorem, let us presumably have access to some features and , which are of dimension and , respective. For the infinite case we can take and since the complexity does not depending on our proof still follows.
For simplicity, let us define . Firstly, we notice that the quantity is equivalent to in the finite dimensional setting. Let us define . Since
Now, without changing our algorithm, we have that
Thus all the conditions except in 2′ are satisfied (). It will become clear that is absorbed in the definition of .
Since Kernelized MatrixRL is equivalent to MatrixRL when the feature space is finite dimensional, the proof of Theorem 3 is nearly identical with that of Theorem 2. To introduce the dependence of the kernel complexity, we keep as the following form:
By following from the steps of the proof of Theorem 2, we obtain that
Since has the same non-zero eigenvalues with that of , we have