A Unified Framework for Alternating Offline Model Training and Policy Learning
Abstract
In offline model-based reinforcement learning (offline MBRL), we learn a dynamic model from historically collected data, and subsequently utilize the learned model and fixed datasets for policy learning, without further interacting with the environment.
Offline MBRL algorithms can improve the efficiency and stability of policy learning over the model-free algorithms.
However, in most of the existing offline MBRL algorithms, the learning objectives for the dynamic models and the policies are isolated from each other.
Such an objective mismatch may lead to inferior performance of the learned agents.
In this paper, we address this issue by developing an iterative offline MBRL framework, where we maximize a lower bound of the true expected return, by alternating between dynamic-model training and policy learning.
With the proposed unified model-policy learning framework, we achieve competitive performance on a wide range of continuous-control offline reinforcement learning datasets. Source code is publicly released.
Introduction
Offline reinforcement learning (offline RL) [1, 2], where the agents are trained from static and pre-collected datasets, avoids direct interactions with the underlying real-world environment during the learning process.
Unlike traditional online RL, whose success largely depends on simulator-based trial-and-error [ e g. , 3, 4], offline RL enables training policies for real-world applications, where it is infeasible or even risky to collect online experimental data, such as robotics, advertisement or dialog systems [ e.g. , 5–8].
Though promising, it remains challenging to train agents under the offline setting, due to the discrepancy between the distribution of the offline data and the state-action distribution induced by the current learning policy.
With such a discrepancy, directly transferring standard online off-policy RL methods [ e.g. , 9–11] to the offline setting tends to be problematic [12, 13], especially when the offline data cannot sufficiently cover the state-action space [14].
To tackle this issue in offline RL, recent works [ e.g. , 15–17] propose to approximate the policy-induced state-action distribution by leveraging a learned dynamic model to draw imaginary rollouts.
These additional synthetic rollouts help mitigate the distributional discrepancy and stabilize the policy-learning algorithms under the offline setting.
Most of the prior offline model-based RL (MBRL) methods [ e.g. , 16, 18–21], however, first pretrain a one-step forward dynamic model via maximum likelihood estimation (MLE) on the offline dataset, and then use the learned model to train the policy, without further improving the dynamic model during the policy learning process.
As a result, the objective function used for model training ( e.g. ,
MLE) and the objective of model utilization are unrelated with each other.
Specifically, the model is trained to be “simply a mimic of the world,” but is used to improve the performance of the learned policy [22–24].
Though such a training paradigm is historically rooted [25, 26], this issue of objective mismatch in the model training and model utilization has been identified as problematic in recent Systems (NeurIPS works [23, 24].
In offline MBRL, this issue is exacerbated, since the learned model can hardly be globally accurate, due to the limited amount of offline data and the complexity of the control tasks.
Motivated by the objective-mismatch issue, we develop an iterative offline MBRL method, alternating between training the dynamic model and the policy to maximize a lower bound of the true expected return.
This lower bound, leading to a weighted MLE objective for the dynamic-model training, is relaxed to a tractable regularized objective for the policy learning.
To train the dynamic model by the proposed objective, we need to estimate the marginal importance weights (MIW) between the offline-data distribution and the stationary state-action distribution of the current policy [27, 28].
This estimation tends to be unstable by standard approaches [ e.g. , 29, 30], which require saddle-point optimization.
Instead, we propose a simple yet stable fixed-point-style method for MIW estimation, which can be directly incorporated into our alternating training framework.
With these considerations, our method, offline Alternating Model-Policy Learning (AMPL), performs competitively on a wide range of continuous-control offline RL datasets in the D4RL benchmark [31].
These empirical results and ablation study show the efficacy of our proposed algorithmic designs.
Background
Markov decision process and offline RL.
A Markov decision process (MDP) is denoted by M = ( S , A , P, r, γ, µ 0 ) , where S is the state space,
A the action space, P ( s ′ | s, a ) : S × S ×
A → [0 , 1] the environmental dynamic, r ( s, a ) : S ×
A → [ − r max , r max ] the reward function, γ ∈ [0 , 1) the discount factor, and µ 0 ( s ) : S → [0 , 1] the initial state-distribution.
For any policy π ( a | s ) , we denote its state-action distribution at timestep t ≥ 0 as d Pπ,t ( s, a ) ≜
Pr ( s t = s, a t = a | s 0 ∼ µ 0 , a t ∼ π, s t +1 ∼ P, ∀ t ≥ 0) .
The (discounted) stationary state-action distribution of π is denoted as d Pπ,γ ( s, a ) ≜ (1 − γ ) (cid:80) ∞ t =
γ t d Pπ,t ( s, a ) .
Denote Q Pπ ( s, a ) =
E π,P [ (cid:80)
∞
t =0 γ t r ( s t , a t ) | s
=
s, a 0 = a ] as the action-value function of policy π under the dynamic P .
The goal of RL is to find a policy π maximizing the expected return
[Equation]
In offline RL, the policy π and critic Q Pπ are typically approximated by parametric functions π ϕ and
Q θ , respectively, with parameters ϕ
and θ .
The critic Q θ is trained by the Bellman backup
[Equation]
where Q θ ′ is the target network [12, 13].
The actor π ϕ is trained in the policy improvement step by
[Equation]
where D env denotes the offline dataset drawn from d Pπ b ,γ [2, 32], with π b being the behavior policy.
Offline model-based RL.
In offline model-based RL algorithms, the true environmental dynamic
P ∗ is typically approximated by a parametric function (cid:98) P ( s ′ | s, a ) in some function class P .
With the offline dataset D env , (cid:98) P is trained via the MLE [15, 16, 18] as
[Equation]
Similarly, the reward function can be approximated by a parametric model (cid:98) r if assumed unknown.
With (cid:98) P and (cid:98) r , the true MDP M can be approximated by (cid:99) M =
( S , A , (cid:98) P, (cid:98) r, γ, µ 0 ) .
We further define d P ∗ π,γ ( s, a ) as the stationary state-action distribution induced by π on P ∗ (or MDP M ), and d (cid:98) Pπ,γ ( s, a ) as that on the learned dynamic (cid:98) P (or MDP (cid:99) M ).
We approximate d P ∗ π ϕ ,γ by simulating π ϕ on (cid:99) M for a short horizon h starting from state s ∈ D env , as in prior work [ e.g. , 16, 18, 19, 21].
The resulting transitions are stored in a replay buffer D model , constructed similar to the off-policy RL [33, 9].
To better approximate d P ∗ π ϕ ,γ , sampling from D env in Eqs.
(2) and (3) is commonly replaced by sampling from the augmented dataset D =
f D env
+ (1 − f ) D model , f ∈ [0 , 1] , denoting sampling from D env and
D model with probabilities f and 1 − f , respectively.
We follow Yu et al.
[18] to use f = 0 .
Offline alternating model-policy learning
Our goal is to derive the objectives for both dynamic-model training and policy learning from a principled perspective.
A natural idea is to build a tractable lower bound for J ( π, P ∗ ) , the expected return of the policy π under the true dynamic P ∗ , and then alternate between training the policy π and the dynamic model (cid:98) P to maximize this lower bound.
Indeed, we can construct a lower bound as
[Equation]
where J ( π, (cid:98) P ) is the expected return of policy π under the learned model (cid:98) P .
From the right hand side (RHS) of Eq.
(5), if the policy evaluation error | J ( π, P ∗ ) − J ( π, (cid:98) P ) | is small, J ( π, (cid:98) P ) will be a good proxy for the true expected return J ( π, P ∗ ) .
We can empirically estimate J ( π, (cid:98) P ) via (cid:98) P and π .
Further, if a tractable upper bound for | J ( π, P ∗ ) − J ( π, (cid:98) P ) | can be constructed, it can serve as a unified training objective for both dynamic model (cid:98) P and policy π .
We can then alternate between optimizing the dynamic model (cid:98) P and the policy π to maximize the lower bound of J ( π, P ∗ ) , i.e. , simultaneously minimizing the upper bound of the evaluation error | J ( π, P ∗ ) − J ( π, (cid:98) P ) | .
This gives us an iterative, maximization-maximization algorithm for model and policy learning.
The following theorem indicates a tractable upper bound for | J ( π, P ∗ ) − J ( π, (cid:98) P ) | , which can be subsequently relaxed for model training and policy learning.
Theorem 1.
Let P ∗ be the true dynamic and (cid:98) P be the approximate dynamic model.
Suppose the reward function | r ( s, a ) | ≤ r max , then we have
[Equation]
with D π ( P ∗ , (cid:98) P ) ≜ E ( s,a ) ∼ d P ∗ πb,γ (cid:104)
[Equation]
[Equation]
a
[Equation]
, where π b is the behavior policy, d P ∗ π b ,γ is the offline-data distribution, and ω ( s, a ) ≜
d P ∗ π,γ ( s,a ) d P ∗ πb,γ ( s,a ) is the marginal importance weight (MIW) between the offline-data distribution and the stationary state-action distribution of the policy π [27, 29].
Detailed proof of Theorem 1 can be found in Appendix B.2.
The KL term in D π
( P ∗ , (cid:98) P ) indicates the following two principles for model and policy learning:
⋆ For the dynamic model, s ′ ∼ (cid:98) P ( · | s, a ) should be close to the true next state ˜ s ′ ∼ P ∗ ( · | s, a ) , with ( s, a ) pairs drawn from the stationary state-action distribution of the policy π .
Since we cannot directly draw samples from d P ∗ π,γ , we reweight the offline data with ω ( s, a ) .
This leads to a weighted KL minimization objective for the model training.
⋆ For the policy π , the KL term indicates a regularization term, that the tuple ( s ′ , a ′ ) from the joint conditional distribution (cid:98) P ( s ′ | s, a ) π ( a ′ | s ′ ) should be close to the tuple (˜ s ′ , ˜ a ′ ) from
P ∗ (˜ s ′ | s, a ) π b
(˜ a ′ | ˜ s ′ ) .
(˜ s ′ , ˜ a ′ ) is simply a sample from the offline dataset.
Based on the above observations, we can fixed π and train the dynamic model (cid:98) P by minimizing
D π ( P ∗ , (cid:98) P ) w.r.t. (cid:98) P .
Similarly, we can fix the dynamic model (cid:98) P and learn a policy π to maximize the lower bound of J ( π, P ∗ ) .
This alternating training scheme provides a unified approach for model and policy learning.
In the following sections, we discuss how to optimize the dynamic model (cid:98) P , the policy π , and the MIW ω under our alternating training farmework.
3.1 Dynamic model training
Expanding the KL term in D π ( P ∗ , (cid:98) P ) , we have
[Equation]
where the tuple ( s, a, s ′ , a ′ ) is simply two consecutive state-action pairs in the offline dataset.
Further, if the policy π is fixed, the term 1 is a constant w.r.t. (cid:98) P .
Thus, given the MIW ω , we can optimize (cid:98) P by minimizing the following loss
[Equation]
which is an MLE objective weighted by ω ( s, a ) .
We discuss how to estimate ω ( s, a ) in Section 3.3.
3.2 Policy learning
The lower bound for J ( π, P ∗ ) implied by Theorem 1 is
[Equation]
where J ( π, (cid:98) P ) can be estimated via the action-value function similar to standard offline MBRL algorithms [ e.g. , 16, 18, 19].
Thus, when the dynamic model (cid:98) P is fixed, the main difficulty is to estimate the regularizer D π ( P ∗ , (cid:98) P ) for the policy π .
When the policy π is Gaussian, direct estimation of D π
( P ∗ , (cid:98) P ) is possible.
Empirically, however, it is helpful to learn the policy π in the class of implicit distribution, which is a richer distribution class and can better maximize the action-value function.
Specifically, given a noise distribution p z ( z ) , action a = π ϕ ( s, z ) with z ∼ p z ( · ) , where π ϕ is a deterministic network.
Unfortunately, we can not directly estimate the KL term in D π
( P ∗ , (cid:98) P ) if π is an implicit policy, since we can only draw samples from π but the density is unknown.
A potential solution is to use the dual representation of KL divergence KL( p || q ) =
sup T E p [ T ] − log( E q [ e T ])
[34], which can be estimated with samples from the distributions p and q .
However, the exponential function therein makes the estimation unstable in practice [30].
We instead use the dual representation of the Jensen–Shannon divergence (JSD) to approximate D π
( P ∗ , (cid:98) P ) , which can be approximately minimized using the GAN structure [35, 36].
Our framework can thus utilize the many stabilization techniques developed in the GAN community (Appendix E.2.1).
Besides, we remove the MIW ω ( s, a ) during the policy training since we do not observe its empirical benefits, which will be discussed in Section 4.2.
Further applying the replacement of KL with JSD and ignoring the √· for numerical stability, we get an approximated new regularization for policy π :
[Equation]
Informally speaking, Eq.
(8) regularizes the imaginary rollouts of π on (cid:98) P towards state-action pairs from the offline dataset.
Intuitively, (cid:101)
D π ( P ∗ , (cid:98) P ) is a more effective regularizer for policy training than the original D π ( P ∗ , (cid:98) P ) , since (cid:101)
D π ( P ∗ , (cid:98) P ) regularizes action choices at both s and s ′ .
Appendix B. discusses how we move from D π
( P ∗ , (cid:98) P ) to (cid:101)
D π ( P ∗ , (cid:98) P ) in detail.
3.3 Marginal importance weight training
A number of methods have been recently proposed to estimate the marginal importance weight ω [27, 29, 30].
These methods typically require solving a complex saddle-point optimization, casting doubts on their training stability especially when combined with policy learning on continuous-control offline MBRL problems.
In this section, we mimic the Bellman backup to derive a fixed-point-style method for estimating the MIW.
Denote the true MIW as ω ∗ ( s, a
[Equation]
s,
[Equation]
) , we have d P ∗
[Equation]
b , [Equation] [Equation]
Expanding the RHS, ∀ s ′ , a ′ ,
[Equation]
The derivation is deferred to Appendix B.4.
Therefore, a “ Bellman equation ” for ω ( s ′ , a ′ ) is
[Equation]
Here T can be viewed as the “ Bellman operator ” for ω .
The update iterate defined by T has the following convergence property, which is proved in Appendix B.5.
Proposition 2.
On finite state-action space, if the current policy π is close to the behavior policy π b , then the iterate for ω defined by T converges geometrically.
The assumption that π is close to π b coincides with the regularization term in the policy-learning objective discussed in Section 3.2.
Unfortunately, the RHS of Eq.
(9) is not estimable since we do not know the density values therein.
We therefore multiply both sides of Eq.
(9) by some test function and subsequently sum over ( s ′ , a ′ ) on both sides to get a tractable objective that only requires samples from the offline dataset and the initial state-distribution µ 0 .
It is desired to choose a test function that can better distinguish the difference between the left-hand side (LHS) and the RHS of Eq.
A potential choice is the action-value function of the policy π , due to some primal-dual relationship between the stationary state-action density-(ratio)
( d P ∗ π,γ ( s, a ) or ω ∗ ( s, a ) ) and the action-value function [37–39].
A detailed discussion on the choice of the test function is provided in Appendix C.
Practically we use Q (cid:98) Pπ as the test function.
Note that multiplying both sides of Eq.
(9) by the same Q (cid:98) Pπ does not undermine the convergence property, under mild conditions on Q. Mimicking the Bellman backup to sum over ( s ′ , a ′ ) on both sides, with the notation d
[Equation]
Thus for a given ω , we can optimize ω by minimizing the difference between the RHS and the LHS of
Eq.
For training stability, we use a target network ω ′ ( s, a ) for the RHS, and the final objective for learning ω is
[Equation]
where the target network ω ′ ( s, a ) is soft-updated after each gradient step, motivated by Q θ ′
j and π ϕ ′ .
Our proposed training method is closely related to VPM [40].
By using the MIW ω ( s, a ) itself as the test function, VPM leverages the variational power iteration to train MIW iteratively.
Instead, our approach uses the current action-value function as the test function, motivated by the primal-dual relationship between the MIW and the action-value function in off-policy evaluation.
We compare the empirical performance of several alternative approaches in Section 4.2 and in Table 3 of Appendix A.
3.4 Practical implementation
In this section we briefly discuss some implementation details of our offline Alternating Model-Policy Learning (AMPL) method, whose main steps are in Algorithm 1.
Further details are in Appendix E.1.
Dynamic model training.
We adopt common practice in offline MBRL [ e.g. , 16, 18] to use an ensemble of Gaussian probabilistic networks (cid:98) P ( · | s, a ) and ˆ r ( s, a ) to parameterize the stochastic transition and reward.
We initialize the dynamic model by standard MLE training, and periodically
Critic training.
We use the conservative target in the offline RL literature [ e.g. , 12, 13]:
[Equation]
where we set c = 0 .
With mini-batch B sampled from the augmented dataset D , both critic networks are trained as
[Equation]
where the Huber loss Huber( · ) is used in lieu of the classical MSE for training stability [41].
Estimating (cid:101)
D π ( P ∗ , (cid:98) P ) .
In (cid:101) D π ( P ∗ , (cid:98) P ) , using the notations of GAN, we denote the sample from the left distribution of JSD in Eq. (8) by B true ( i.e. , “true” sample), and the sample from the right distribution of JSD by B fake ( i.e. , “fake” sample).
The “true” sample B true consists of samples from D env .
The “fake” sample B fake is formed by first sampling s ∼ D , followed by a ∼ π ϕ ( · | s ) , s ′ ∼ (cid:98) P ( · | s, a ) , a ′ ∼ π ϕ ( · | s ′ ) .
Concretely, the “fake” sample
B fake , generator loss L g ( ϕ ) , and the discriminator loss L D ( ψ ) can be described as
[Equation]
[Equation]
where L g ( ϕ ) is the empirical policy-learning regularizer implied by (cid:101)
D π ( P ∗ , (cid:98) P ) .
Policy training.
Since the constant multiplier in Eq.
(7) is unknown, we treat it as a hyperparameter.
Adding the regularization term of policy training, our policy optimization objective is
[Equation]
where the regularization coefficient λ ≜ λ ′ /Q
avg , with soft-updated Q avg similar to Fujimoto and
Gu [42].
We use λ ′
= 10 across all datasets in our experiments (Section 4).
Experiments
In this section, we first evaluate our AMPL on continuous-control offline-RL datasets in Section 4.1.
Then we conduct ablation study on Section 4.2 to understand the efficacy of some proposed designs.
4.1 Continuous-control results
Our experiments are conducted on a diverse set of datasets in the D4RL benchmark [31], ranging across the Gym-Mojoco, Maze2D, and Adroit domains therein.
We use the latest version of the datasets, i.e. , “v2” version for the Gym-Mojoco domain and “v1” version for the Maze2D and Adroit domains.
Details of our dataset choice are discussed in Appendix E.2.
We compare our AMPL with two DICE methods — AlgaeDICE [43] and OptiDICE [44] — that directly utilize MIW to improve policy learning.
We further consider three state-of-the-art (SOTA) offline model-free RL algorithms: CQL [45], FisherBRC [46], and TD3+BC [42]; and three SOTA offline MBRL methods: MOPO [16], COMBO [18], and WMOPO [47].
Experimental details and hyperparameter settings are discussed in Appendix E.2.
We run baseline methods using the official implementation under the recommended hyperparameters, except for AlgaeDICE, for which we use the offline version provided by Fu et al.
Table 1 shows the mean and standard deviation of the results of AMPL and baselines over five random seeds.
As shown in Table 1, our AMPL performs comparably well and is relatively stable across the sixteen tested datasets.
In particular, AMPL generally performs better than the baselines on the Maze2D and Adroit datasets.
The Maze2D and Adroit datasets are considered as more challenging than the
MuJoCo datasets [31], since the Maze2D datasets are collected by non-Markovian policies, and the amount of data in the high-dimensional Adroit datasets is limited.
[Table]
On the Maze2D datasets
[Table]
the behavioral-cloning (BC) style algorithms, such as FisherBRC, are likely to fail, since these methods use Markovian policy to approximate the non-Markovian behavior policy.
Meanwhile
[Table]
OptiDICE performs relatively well on the Maze2D datasets, mainly because it uses a
Gaussian-mixture policy for BC to alleviate this approximation difficulty.
This advanced BC policy still offers little help on the higher-dimensional Adroit datasets, due to the challenge of learning the behavior policy.
Similarly, TD3+BC performs well on the relatively lower-dimensional Maze2D datasets, but does not work well on the Adroit domain, since the action-space MSE-regularizer in TD3+BC may be insufficient for the high-dimensional tasks.
WMOPO also shows a performance drop in these two challenging task domains.
The environmental dynamics on these two domains are complex, and thus may not be accurately learned to support WMOPO’s full-trajectory model rollouts, which are used to estimate its MIW.
By contrast, our AMPL does not require BC or long model-rollouts, leading to stable performance across task domains.
Moreover, AMPL shows generally better performance than MOPO and COMBO, which use fixed pretrained dynamic models without considering the mismatched model objectives.
Compared with the DICE-based methods AlgaeDICE and OptiDICE, our AMPL shows generally better performance.
This may indicate that maximizing a lower bound of the true expected return can be a more effective framework than explicit stationary-distribution correction, since maximizing the lower bound is more directly related to RL’s goal of maximizing the policy performance.
[Figure]
4.2 Ablation study
(a): Does the MIW-weighted model (re)training help the performance?
[Figure]
To verify the effectiveness of our MIW-weighted model (re)training scheme [Figure] we compare our AMPL with its variant of training the model only at the beginning using MLE, i [Figure]
e. , No Weights (dubbed as NW). As shown in Figure [Figure] the performance of the NW variant is generally worse than the main method (dubbed as Main) on all three domains.
The performance difference is especially significant on the Maze2D domain.
In this domain, the policy is required to “stitch together collected subtrajectories to find the shortest path to the evaluation goal” [31].
As a result, the state-action distribution induced by a good policy should be different from the distribution of the offline-data.
Table 2 in Appendix A confirms the benefit of the MIW-weighted model (re)training.
Indeed, on the majority of datasets, the NW variant not only shows worse performance, but also has a larger standard deviation relative to the mean score. (b): How does the algorithm perform if we change our MIW estimation method to other approaches?
We compare our AMPL with its three variants where the MIW is instead estimated by the Variational
Power Method [40], GENeralized stationary DIstribution Correction Estimation [30], and Dual stationary DIstribution Correction Estimation [29].
Three variants are simply dubbed as VPM,
GenDICE, and DualDICE.
For numerical stability, the estimated MIW from these three methods is clipped into (10 − 8 , 500) .
Implementation details are provided in Appendix E.3.
As shown in Figure 1 and Table 2, the variants with these three alternative MIW estimation methods generally perform worse than our approach.
A plausible explanation is that these methods can be unstable to provide good MIW estimates for the model training.
Figure 2 shows the distribution plots of log ( MIW ) of the entire dataset estimated by our method and by the variants using the three alternative MIW estimation methods, on the “walker2d-medium-replay” dataset.
We train the MIW every 100 epochs and ignore the MIW initialization from the plots.
Notice that the MIWs obtained by these four methods have very different scales, which indicates the instability of the alternative methods compared with ours.
As shown on Figure 2b, the MIWs estimated by the GenDICE variant degenerate, in a sense that most of the MIWs are ≈ 0 at the begining and are 1 later on, with long tails on the MIW distributions.
This may explain the relatively bad performance of GenDICE.
Compared with GenDICE, DualDICE provides more diverse MIW estimates, which leads to its relatively better performance.
Unfortunately,
Figure 2c shows that, for the DualDICE variant, the distribution of MIWs gradually concentrates on very small and very large values, which indicates the degeneration of the MIWs.
The VPM variant performs the best among these three alternatives, mainly because it provides relatively better MIW estimates in the second half of the training process.
However, Figure 2a shows that the MIWs from the VPM variant are poorly-distributed at the beginning, though relatively better later on.
Our method provides well-behaved MIW estimates in the whole training process, which may explain our better result.
As shown by Figure 2d, the MIWs from our method are well-shaped and concentrate around the mean 1 1 over the entire training process.
In general, the well-shaping of the estimated MIW is important, since the Cramer-Rao lower bound of the mean-square-error for OPE is related to the square of the density ratio [38, 48].
Besides, on the Maze2D domain, these three variants using the alternative MIW estimation methods perform generally better than the NW variant discussed in Question (a) , aligning with the benefit of the MIW-weighted model (re)training scheme.
Generally speaking, incorporating the MIW can help model training in offline MBRL. (c): What is the performance of a weighted regularizer for policy learning implied by Theorem 1?
We compare our AMPL with its variant where the policy regularizer is weighted by the MIW ω ( s, a ) , as suggested by Theorem 1.
This Weighted Policy Regularizer variant is dubbed as WPR.
As shown in both Figure 1 and Table 2, the WPR variant underperforms our main method.
This is because when we estimate the regularization term in WPR, we incorporate weights into the minimax optimization of the policy and the discriminator, which may bring additional instability.
Table 3 of Appendix A provides additional ablation study on the performance of several alternatives.
Related work
Offline MBRL.
Most of the existing offline MBRL works focus on policy learning under a given model trained by MLE.
These works typically constrain the learned policy to avoid visiting regions where the discrepancy between the true and the learned dynamic is large, thus reducing the policy evaluation error of using the learned dynamic [16, 19, 49, 50]. Besides, some recent works [51, 52] also adopt a GAN-style stochastic policy for its flexibility. Rather than using
a fixed MLE-trained model , we derive an objective that trains both the policy and the dynamic model toward maximizing a lower bound of true expected return (simultaneously minimizing the policy evaluation error | J ( π, P ∗ ) − J ( π, (cid:98) P ) | ).
Several recent works also propose to enhance model training, such as training a reverse dynamic model to encourage conservative model-based imaginations [53], learning a balanced state-action representation for the model to mitigate the distributional discrepancy [54, 55], and using advanced dynamic-model architecture of the GPT-Transformer [56–59] to achieve accurate predictions [60].
These methods are orthogonal to ours and may further improve the performance.
Objective mismatch in MBRL.
Our AMPL is related to prior works on online and offline MBRL that mitigate the mismatched model objectives.
In online (off-policy) MBRL, Lambert et al.
[23] identify the mismatched objectives between the MLE model-training and the model’s usage of improving the control performance.
This paper, however, only proposes an impractical weighted learning loss that requires the optimal trajectory.
Eysenbach et al.
[24] design an objective to jointly optimize the policy and the model in online MBRL.
Voelcker et al.
[61] propose a per-sample diagonal scaling matrix for training a deterministic model in online RL, which improves on Farahmand et al.
[62] and Farahmand [63].
In offline MBRL, D’Oro et al.
[64] propose a weighting scheme to learn the transition model.
This method requires the behavior policy and estimates the trajectory-wise importance-sampling weight, which is known to suffer from the “curse of horizon” [27].
Thus, this method may not scale to complex high-dimensional offline RL tasks.
Voloshin et al.
[65] propose a minimax objective for model learning, where the model is optimized over function classes of the
MIW and the state-value function.
Most similar to our work, Hishinuma and Senda [47] also use a
MIW-weighted MLE objective for model training.
They use a different version of the MIW estimated via multiple full-trajectory rollouts in the learned model.
This strategy may suffer from the inaccuracy of the learned model [66–68] and can be time-consuming.
In this paper, we develop a fixed-point style method to train the MIW that only requires samples from the offline dataset and the initial state-distribution, which can be more stable and efficient.
Off-policy evaluation (OPE).
OPE [29, 30, 48, 69–74] is a well-studied problem with several lines of research.
A natural way is trajectory-wise importance sampling (IS) [75].
This, however, suffers from its variance, which can grow exponentially with the horizon length [27, 76].
Marginal importance sampling methods [27] are developed to address this problem by estimating the IS ratio between two stationary distributions, leading to estimators whose variance are polynomial w.r.t.
horizon [77].
Though prior works can also be used to estimate the MIW, they may not be directly applicable to our framework, since they either require knowing the behavior policy [27, 37], or need to assume the MIW lying in the space of RKHS [28].
Another approach to estimate the MIW is through saddle-point optimization [29, 30, 39, 78], which can suffer from its complex optimization problem.
In this paper, we derive an fixed-point-style and behavior-agnostic MIW estimation method, which is simple to train and does not require additional assumptions.
Conclusion
In this paper, we are motivated by the mismatched model objectives in offline MBRL to design an iterative algorithm that alternates between model training and policy optimization.
Both the model and the policy are trained to maximize a lower bound of the true expected return.
The proposed new algorithm performs competitively with several SOTA baselines.
Limitation.
Our current approach requires training two additional networks (discriminator D ψ and MIW ω ), and the model is (re)trained periodically to mitigate the objective mismatch, which brings additional computational cost in order to obtain better empirical results.
Future work.
We plan to conduct a theoretical analysis of our proposed framework, and investigate more efficient ways to unify model training and policy learning.
Acknowledgments
S. Yang, S. Zhang, and M. Zhou acknowledge the support of NSF IIS 1812699 and 2212418, and the
Texas Advanced Computing Center (TACC) for providing HPC resources that have contributed to the research results reported within this paper.
Checklist
For all authors... (a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope?
[Yes] See Sections 3 and 4.
(b) Did you describe the limitations of your work?
[Yes] See Sections 5 and 6.
(c) Did you discuss any potential negative societal impacts of your work?
[Yes] See Appendix F. (d) Have you read the ethics review guidelines and ensured that your paper conforms to them?
[Yes] 2.
If you are including theoretical results... (a) Did you state the full set of assumptions of all theoretical results?
[Yes] See Sectionand Appendix B. (b) Did you include complete proofs of all theoretical results?
[Yes] See Appendix B. 3.
If you ran experiments... (a) Did you include the code, data, and instructions needed to reproduce the main experimental results (either in the supplemental material or as a URL)?
[Yes] See Sectionand Appendix E for descriptions.
Source code is publicly released.
(b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)?
[Yes] See Appendix E.2 and E.3.
(c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)?
[Yes] See Tables 1, 2, 3, and 4.
(d) Did you include the total amount of compute and the type of resources used (e.g., type of GPUs, internal cluster, or cloud provider)?
[Yes] See Appendix G. 4.
If you are using existing assets (e.g., code, data, models) or curating/releasing new assets... (a) If your work uses existing assets, did you cite the creators?
[Yes] (b) Did you mention the license of the assets?
[Yes] See the GitHub pages of the assets.
(c) Did you include any new assets either in the supplemental material or as a URL?
[No] (d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating?
[No] We use public benckmarks.
(e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content?
[No] The used benckmarks are widely accepted in the community.
If you used crowdsourcing or conducted research with human subjects...
(a) Did you include the full text of instructions given to participants and screenshots, if applicable?
[N/A] (b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable?
[N/A] (c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation?
[N/A]
Appendix A Additional table
Table 2 presents the numerical results for the ablation study in Section 4.2.
[Table]
Table 3 provides additional ablation study on several building blocks of our main method.
In Table 3, we test the following variants to demonstrate the effectiveness of our framework.
• Main denotes the results of our main method in Section 4.1.
• NW denotes the No-Weights variant in Section 4.2 (a) .
• WPR denotes the Weighted Policy Regularizer variant in Section 4.2 (c) .
• KL-Dual denotes the variant changing the JSD regularizer in Main to the KL( P ∗ ( s ′ | s, a ) π b ( a ′ |
s ′ )
|| (cid:98) P ( s ′ | s, a ) π (
a ′ | s ′ )) term in Theorem 1, where ( s, a ) ∼ d P ∗ π b ,γ and the KL term is estimated via the dual representation KL( p || q ) =
sup T (cid:8) E p
[ T ] − log( E q [ e T ]) (cid:9) [34].
• KL-Dual+WPR denotes the variant changing the JSD regularizer in Main to the weighted KL term D π ( P ∗ , (cid:98) P ) in Theorem 1.
• Gaussian denotes the variant changing the implicit policy in Main to the Gaussian policy.
• No Reg.
denotes the variant removing the proposed regularizer in the policy learning.
• No model-rollout denotes the variant of no rollout data in policy learning. • Rew. Test denotes the variant of using the estimated reward function as the test function when training the MIW ω .
Main denotes the results of our main method in Section 4.1.
NW denotes the No-Weights variant in Section 4.2 (a) .
WPR denotes the Weighted Policy Regularizer variant in Section 4.2 (c) .
KL-Dual denotes the variant changing the JSD regularizer in Main to the KL term in Theorem 1.
KL-Dual+WPR denotes the variant changing the JSD regularizer in Main to the weighted KL term D
( P ∗
P ) in
Gaussian denotes the variant changing the implicit policy in Main to the Gaussian policy the the variant no rollout denotes the variant of using the estimated reward function as the function when training the MIW ω .
Here, “hcheetah” denotes “halfcheetah,” “med” denotes “medium,” “rep” denotes “replay,”
“exp” denotes “expert.”
[Table]
Apart from the discussion in Section 4.2 (a) and Section 4.2 (c) on the NW and the WPR variants.
We see that changing the proposed JSD regularizer in Section 3.2 to the KL-dual-based regularizers breaks the policy learning.
This may be related to the unstable estimation of KL-dual discussed in
Section 3.2.
Changing the implicit policy to the Gaussian policy generally leads to worse performance.
The performance difference is especially significant on the Maze2D and Adroit datasets.
This aligns with the observation in Yang et al.
[51] that a uni-model Gaussian policy may be insufficient to capture the necessary multiple action modes in the Maze2D and Adroit datasets, while an implicit policy is likely to be capable.
Removing the proposed regularization term breaks the policy learning, showing the efficacy of the proposed regularizer.
Removing rollout data in the policy learning generally leads to worse performance and larger standard deviations.
This shows the benefit of adding the model-rollout data, that they can mitigate the off-policy issue by taking into account the rollouts of the learned policy.
Finally, compared with the main method that uses the action-value function as the test function, the Rew.
Test variant generally has worse performance and larger standard deviations.
As discussed in Appendix C, using the (estimated) reward function as the test function loses the nice mathematical properties, and the resulting objective for training the MIW ω may not be easy to optimize.
B Proofs B.1 Preliminary on discounted stationary state-action distribution Recall
that the discounted visitation frequency for a policy π on MDP M with transition P ∗ is defined as
[Equation]
Denote T ∗ π ( s ′ | [Equation]
= p π [Equation] [Equation]
| [Equation] =
[Equation] ∈ [Equation] ∗
[Equation] ′ | s [Equation] = s
[Equation] a [Equation] ) π ( a | s ) .
From Liu et al.
[27], Lemma 3, for d P ∗ π,γ ( s ) we have, γ
[Equation]
where µ 0 is the initial-state distribution.
Multiply π ( a ′ | s ′ ) on both sides, we get, ∀ ( s ′ ,
a ′ ) ∈
S × A ,
[Equation]
We can also multiply (cid:101) π ( a
[Equation]
| s ′ ) on both sides to get, ∀ ( s [Equation] , a [Equation]
) ∈ S × A
[Equation]
Denote d P ∗ π,γ ( s, a, s ′ ) ≜
d P ∗ π,γ ( s ) π ( a | s ) P ∗ ( s ′ | s, a ) .
For any integrable function f ( s, a ) , we multiply both sides of the above equation by f ( s ′ , a ′ ) and summing over s ′ , a ′ , we get γ [Equation] [Equation]
[Equation]
For any given bounded function g ( s, a ) , define function f to satisfy
[Equation]
then we have E
[Equation]
based on the definition of d P ∗ π,γ ( s, a ) stated above.
Indeed, f ( s, a ) is the action-value function of policy π under the reward g ( s, a ) on MDP M , and can be approximated using neural network under the classical regularity assumptions on g ( s, a ) and
M .
Also, under these classical regularity conditions, reward function g and its action-value function f have one-to-one correspondence, with f being the unique solution to the Bellman equation.
B.2 Proofs of Theorem
The following Lemma will be used in the proof of Theorem 1.
Lemma 3.
For any (cid:98) P ( s ′ | s, a ) , π ( a ′ | s ′ ) , P ∗ ( s ′ | s, a ) , π b ( a ′ | s ′ ) , we have
[Equation]
[Equation]
[Equation]
Proof.
Since KL( · || · ) ≥ [Equation] we have
[Equation]
as desired
[Equation]
Remark 4 .
It also holds that
[Equation]
by using similar proof steps
[Equation]
Proof of Theorem 1.
[Equation]
[Table]
[Equation]
[Table]
[Equation]
[Table]
[Equation]
[Table]
[Equation]
[Table]
[Equation]
[Table]
[Equation]
[Table]
[Equation]
[Table]
[Equation]
[Table]
[Equation]
[Table]
[Equation]
[Table]
[Equation]
[Table]
[Equation]
[Table]
[Equation]
[Table]
[Equation]
where V is the set of functions bounded by
1 , ω ( s, a ) ≜
d P ∗ π,γ ( s,a ) d P ∗ πb,γ ( s,a ) is the marginal importance weight (MIW).
Here we use the assumption that ∀ s, a, | r ( s, a ) | ≤ r max , and hence | V (cid:98) Pπ ( · ) | ≤ r max 1 − γ .
We use Lemma 3 to introduce π and π b into KL ( · || · ) .
B.3 Derivation of Eq. (8)
Derivarion of Eq.
We follow the literature [ e [Equation] g. , 79, 80] to assume that ∀ s, a, ω ( s, a ) ≤ ω max for some unknown finite constant ω max .
Using Remark 4 and this assumption, we have
[Equation]
where we approximate the KL divergence by the JSD.
B.4 Derivation of Eq. (9)
Derivarion of Eq.
We have, ∀ ( s, a ) ∈ S ×
[Equation]
where T ∗ π ( s ′ | s )
= (cid:80)
a ∈ A P ∗ ( s ′ | s, a ) π ( a | s ) is the state-transition kernel.
Here we change ( s, a ) into ( s ′ , a ′ ) in the “ ⇐⇒ ” for notation simplicity.
B.5 Proof of Proposition
Proof of Proposition 2.
With the assumed conditions, we would like to show that T is a contraction mapping under ∥ · ∥ ∞ , i.e. , ∥T ω − T u ∥ ∞ ≤ c · ∥ ω − u ∥ ∞ , for all MIWs ω, u : S ×
A → R , for some constant c < 1 .
We have,
[Equation]
 
[Equation]

[Equation]
If the current policy π is close to the behavior policy π b , in a sense that π ( a ′ | s ′ )
π b ( a ′ | s ′ ) is close to 1 on the entire finite state-action space, specifically,
[Equation]
Then c = max s [Equation] [Equation] π
[Equation]
a ′ | s [Equation] [Equation] b
[Equation]
| s ′ ) · c ( s [Equation] ) (cid:111) < 1 .
Plug into Eq.
(20), we have ∥T ω −T u ∥ ∞ ≤ c ·∥ ω − u ∥ ∞ for c < 1 .
Thus T is a c -contraction mapping under ∥ · ∥ ∞ .
It follows that there exists a unique fixed point ω ∗ under the mapping
T , such that ω ∗ =
T ω ∗ .
Finally, we have ∥ [Equation] , as k
[Equation]
∞ , which shows that the iterate defined by T converges geometrically. C Discussion on the choice of test function for MIW
We first discuss the original minimax optimization loss [27, 30, 81] for learning the MIW ω ( s, a ) . When given an offline dataset D env , the objective is
[Equation]
where f ∈ F is a test function similar to the discriminator in adversarial training.
A number of prior works on learning ω ( s, a ) ( e.g. DualDICE [29], GenDICE [30]) can be viewed as variants of the above minimax objective, with some additional regularization terms on ω ( s, a ) . For example, there is an additional 1 2 ω 2 term in DualDICE to penalize ω so that the resulting MIW values ω ( s, a ) will not be too large. This term thus serves as a regularization. However, the optimization process for ω ( s, a ) in Eq.
(21) can be unstable due to the following two reasons: (1) the minimax optimization is itself a challenging problem, especially for neural-networkbased function approximator; (2) when we fix f ( s, a ) and optimize ω ( s, a ) , the gradients for ω that come from γω ( s, a )
f ( s ′ , a ′ )
and ω ( s, a ) f ( s, a ) are close to each other, especially when γ is close to 1 ( e.g. , 0 . 99 ).
This makes the overall gradient for ω small and unstable, especially when we use stochastic gradient descent to optimize ω .
The empirical distributions of the MIW from DualDICE and GenDICE in Fig.
2 illustrate the optimization difficulty of these two methods.
Therefore, we wish to get rid of the minimax optimization and stabilize the training process.
Another closely related work that also tries to address the aforementioned issues is VPM [40], where the authors use the MIW ω itself as the test function f , based on the observation that the optimum test function under the f -divergence is the MIW; and use the variational power iteration to solve for ω .
We refer to Wen et al.
[40] for the detailed derivations.
Empirically, we can observe in Fig.
2a that the distribution of ω ( s, a ) obtained by VPM tends to be more stable than those obtained by DualDICE and GenDICE.
Our choice of the test function is motivated by the following constrained optimization formulation of off-policy evaluation [37, 81]:
[Equation]
One can show that Q P ∗ π ( s, a ) is the optimal solution of the above (primal) optimization problem.
The dual form of this optimization problem can be reformulated as
[Equation]
One can show that the stationary distribution d P ∗ π,γ is the solution to the above dual problem.
For the dual problem, we introduce the Lagrange multiplier Q ( s, a ) for each ( s, a ) tuple, and the
Lagrangian can be written as
[Equation]
From the previous observations, the optimal Lagrange multiplier for this Lagrangian is Q P ∗ π
( s, a ) , which is the solution to the primal problem.
Changing d to the MIW ω , we have
[Equation]
where the first term 1 ⃝ estimates the expected return J ( π, P ∗ ) via ω ( s, a ) , which is accurate if ω is the true density ratio.
The second term 2 ⃝ of Eq.
(22) is a loss for ω ( s, a ) as in Eq.
(21), except that we replace the test function f ( s, a ) with Q ( s, a ) .
With the optimal Lagrange multiplier Q P ∗ π ( s, a ) , we can get rid of the inner minimization of the original maximin problem.
In practice, since Q P ∗ π is unknown, one may directly set Q to be the “estimated optimal multiplier” Q (cid:98) Pπ and optimize ω solely.
From Eq.
(22), the MIW ω can be optimized via two alternative approaches.
(1) We can directly optimize ω with L ( ω, Q (cid:98) Pπ ) , whose optimum should be close to J ( π, P ∗ ) .
(2) We can optimize ω w.r.t.
2 ⃝ , because we know that if 2 ⃝ is close to zero, ω is close to the true MIW, and the resulting
L ( ω, Q (cid:98) Pπ ) is again close to J ( π, P ∗ ) based on the term 1 ⃝ .
In theory the main difference of these two approaches is that we may obtain a more accurate estimate for J ( π, P ∗ ) using approach (1) since we optimize ω on both the first and the second terms.
However, since the true reward function r ( s, a ) is unknown, when we optimize ω using approach (1) , the optimization process may be unstable due to the approximation error for r ( s, a ) .
By contrast, for approach (2) , we know that ω is accurate when 2 ⃝ is close to zero, thus we can leverage the MSE loss to optimize ω so that 2 ⃝ is shrunk towards zero.
This approach is similar to the supervised learning and can be more stable in practice.
Since our goal is to obtain a good estimate of the MIW ω , not the numerical value of J ( π, P ∗ ) , we therefore choose approach (2) that optimize ω w.r.t.
2 ⃝ .
Another intuitive motivation for using Q P ∗ π as the test function is that the minimax loss Eq.
(21) for optimizing ω is based on a saddle-point optimization , and f ∈ F is the dual variable for the
MIW ω .
From the previous discussion, MIW and the action-value function have some primal-dual relationship, and Q P ∗ π is the optimal “dual” variable for the off-policy evaluation problem w.r.t.
the
MIW ω .
Since the dual variable f in Eq.
(21) is indeed some action-value function [29], we may set f to be this optimal “dual” of ω , which will lead to the choice of Q P ∗ π as the test function.
Remark.
Note that both our approach and VPM choose the test function based on some mathematical relationships between the test function and the MIW ω , so that the objective for ω could potentially be easier to optimize.
Both methods are not the best theoretical way to optimize ω .
The best theoretical way is simply using the saddle-point-optimization based methods such as DualDICE,
GenDICE, or a direct minimax optimization on L ( ω, Q ) in Eq.
However, as we discussed above, there are some practical difficulties for the saddle-point-optimization based approaches.
As we observed in Fig.
2, the empirical results indeed show that our approach and VPM are more stable than DualDICE and GenDICE.
Further, it is feasible to use other functions as the test function, such as the reward function or any other initialized neural networks.
However, these choices may not have nice mathematical properties, such as being the fixed-point solution or some primal-dual relationship, and thus the resulting objective may not be easier to optimize.
Table 3 in Appendix A contains an ablation study where we use the reward function as the test function to optimize ω .
Indeed, this variant generally performs worse than our main method that uses the Q-function as the test function.
D Using value function as the discriminator of model training
Eq.
(18) of the proof of Theorem 1 motivates us to use the value function V (cid:98) Pπ ( · ) as the discriminator of the model training.
Specifically, the model training objective is arg
[Table]
[Equation]
[Table]
[Equation]
[Table]
[Equation]
[Table]
[Equation]
[Table]
[Equation]
[Table]
[Equation]
[Table]
[Equation]
[Table]
[Equation]
[Table]
[Equation]
[Table]
[Equation] [Table] [Equation] 23) where the discriminator V (cid:98) Pπ can be implemented by the current estimate of the action-value function, which is treated as fixed during the model training.
We implement this idea as a variant where the model is trained by the weighed objective Eq.
(23) that uses the value-function estimate to discriminate the predicted transition from the real.
The reward function ˆ r is still estimated by the weighted-MLE objective.
The model is initialized by the MLE loss.
Other technical details follow the main algorithm.
We dubbed this variant as “V-Dis”.
Table 4 compares this variant with our main method.
We see that V-Dis underperforms our main method on almost all dataset, often by a large margin.
The inferior results of V-Dis may be related to the coupled effect on model training from the inaccurate value-function estimation.
In Eq.
(23), this inaccuracy can affect both the value difference (the |·| term) and the MIW ω .
Our fix of V (cid:98) Pπ during the model training process may also affect the performance.
Future work can investigate how to train
V (cid:98) Pπ together with (cid:98) P in the model estimation.
E Technical details E.1 Details for the main algorithm
Our main algorithm consists of three major components: model training (Appendix E.1.1), the marginal importance weight training (Appendix E.1.2), and RL policy training via actor-critic algorithm (Appendix E.1.3).
The non-zero assumption of Q (cid:98) Pπ in the derivation of Eq.
(11) motivates us to scale the rewards in the offline dataset to be roughly within (0 , 1] , similar to Chen et al.
Specifically, before starting our main algorithm, we normalize the rewards r
i ’s in the offline dataset via ( r i − r min + 0 .
( r max − r min ) , where r min and r max respectively denote the minimum and maximum reward in the offline dataset.
[Table]
We follow the literature [83, 15, 16, 47] to assume no prior knowledge about the reward function and thus use neural network to approximate transition dynamic and the reward function.
Our model is constructed as an ensemble of Gaussian probabilistic networks .
Except for the weighted loss function, we use the same model architecture, ensemble size (=7), number of elite model (=5), train-test set split, optimization scheme, elite-model selection criterion, and sampling method as in Yu et al.
To save computation, we define each epoch of model training as 1000 mini-batch gradient steps, instead of the original n_train / batch_size .
As in Yu et al.
[16], the input to our dynamic model is (cid:0) ( s, a ) − µ ( s,a ) (cid:1) /σ
( s,a ) , where µ ( s,a ) and σ ( s,a ) are respectively coordinate-wise mean and standard deviation of ( s, a ) in the offline dataset.
We follow Kidambi et al.
[19] and Matsushima et al.
[84] to define the learning target as (cid:0) ( r, ∆ s ) − µ ( r, ∆ s ) (cid:1) /σ
( r, ∆ s ) , where ∆ s denote s ′ − s , µ ( r, ∆ s ) and σ ( r, ∆ s ) denote the coordinatewise mean and standard deviation of ( r, ∆ s ) in the offline dataset.
As in prior work using Gaussian probabilistic ensemble on model-based RL [83, 15, 16, 21, 18], we use a double-head architecture for our dynamic model, where the two output heads represent the mean and log-standard-deviation of the normal distribution of the predicted output, respectively.
We augment the maximum likelihood loss in Yu et al.
[16] as the weighted maximum likelihood loss, independently for each model in the ensemble.
Specifically, the dynamic model is initially trained using un-weighted maximum likelihood loss.
We then employ the warm-start strategy to start each subsequent weighted re-training from the current dynamic model, with the weights ω ( s, a ) from the latest marginal importance weight network.
To unify the learning rate across each run of model (re-)training, the weights ω ( s, a ) ’s are normalized so that their mean is 1 across the offline dataset.
To improve training stability, we are motivate by Hishinuma and Senda [47] to heuristically augment the environmental termination function by (1) any( | ˆ s ′ | > 2 · max s,s ′ ∈D env {| s | , | s ′ |} ) where all operations are coordinate-wise, i.e. , whether any coordinate of the predicted next state is outside of this relaxed observation-range in the offline dataset; and
(2) | ˆ r
( s, a ) | > r range ≜ max ( | r min − 10 · σ r | , | r max + 10 · σ r | )) where r min , r max , σ r are the minimum, maximum, and standard deviation of rewards in the offline dataset, i.e. , whether the predicted reward is outside of this relaxed reward-range in the offline dataset.
To penalize the policy for visiting out-of-distribution state-action pair, we modify ˆ r ( s, a ) to be − r range if either (1) or (2) is violated.
No modification for ˆ r
( s, a ) is performed if only the environmental termination is triggered.
E.1.2 Marginal importance weight training
We follow the OPE literature [27, 43, 30] to assume that the initial-state distribution µ 0 is known.
In the implementation, we augment D env with 10 5 samples from the ground-truth µ 0 .
To enhance training stability, we are motivated by the double Q-learning [85] to use a target marginal importance weight network ω ′ ( s, a ) and a target critic network Q ′ ( s, a ) in the implementation of MIW training.
We employ the warm-start strategy so that each retraining of the marginal importance weight starts from the current ω ( s, a ) .
On each run of the weight-retraining, Q ′ is initialized as the current critic target Q θ ′ .
Since the weights ω ( s, a ) ’s are normalized to have mean 1 in the weighted re-training of the dynamic model, to narrow the gap between the learning and the application of the weights, we add a constraint into the training of ω that its mean on each mini-batch is upper bounded by some constant g constraint .
Specifically, on each mini-batch gradient step, MIW is trained by the following constraint optimization
[Equation]
where y
= γ ·
[Equation]
|
[Equation]
[Equation]
where g constraint is conveniently chosen as 10 and B , B init ∼ D env .
To optimize Eq.
(24), we use the constraint optimization method in Gong et al.
[86] with base optimizer Adam [87].
For training stability, the gradient norm is clipped to be bounded by 1 .
As in double Q-learning, we update Q ′ towards Q θ and ω ′ towards ω via exponential moving average with rate 0 .
after each gradient step.
We use batch sizes |B| = 1024 and |B init | = 2048 to train the marginal importance weight model ω ( s, a ) .
E.1.3 Actor-critic training
Our policy training consists of the following six parts.
Generate synthetic data using dynamic model.
We follow Janner et al.
[15] and Yu et al.
[16] to perform h -step rollouts branching from the offline dataset D env , using the learned dynamic (cid:98) P, ˆ r , and the current policy π ϕ .
The generated data is added to a separate replay buffer D model .
To save computation, we generate synthetic data every rollout_generation_freq iterations.
Critic training.
Sample mini-batch B ∼ D = f ·D env
+(1 − f )
·D model , with f ∈ [0 , 1] .
For each s ′ ∈ B , sample one corresponding actions a ′ ∼ π ϕ ′ ( · | s ′ ) .
Calculate the estimate of the action-value of the next state-action pair as
[Equation]
Calculate the critic-learning target defined as
[Equation]
[Equation]
where 2000 is conveniently chosen to enhance the termination condition stored in B for training stability.
Then minimize the critic loss with respect to the double critic networks, over ( s, a ) ∈ B , with learning rate η θ ,
[Equation]
where Huber( · ) denote the Huber-loss with threshold conveniently chosen as 500 .
Finally, the norm of the gradient for critic update is clipped to be bounded by 0 .
1 for training stability.
As a remark, the mentioned enhanced termination condition, Huber loss and gradient-norm clipping are engineering designs for stable training in combating for not knowing the true reward function.
We use a unified setting for these designs across all tested datasets in all experiments, and thus a per-dataset tuning may further improve our results.
Discriminator training.
The “fake” samples B fake for discriminator training is formed by the following steps: first, sample |B| states s ∼ D ; second, for each s get one corresponding action a ∼ π ϕ ( · | s ) ; third, for each ( s, a ) get an estimate of the next state s ′ using (cid:98) P as s ′ ∼ (cid:98) P ( · | s, a ) , with terminal states removed; fourth, sample one next action a ′ for each next state s ′ via a ′ ∼ π ϕ ( · | s ′ ) .
The “fake” samples B fake is subsequently formed by
[Equation]
Note that terminal states are removed since by definition, no action choices are needed on them.
The “true” samples B true consists of |B fake | state-action samples from D env .
The discriminator D ψ is optimized with learning rate η ψ as
[Equation]
Actor training.
The policy is updated once every k updates of the critic and the discriminator.
Using the “fake” samples B fake and the discriminator D ψ , the generator loss for actor training is [Equation]
[Equation]
The policy is optimized with learning rate η ϕ as
[Equation]
where in all tested datasets the regularization coefficient λ ≜ 10 /Q avg with soft-updated Q avg and the penalty coefficient 10 conveniently chosen, similar to Fujimoto and Gu [42].
Soft updates.
We follow Fujimoto et al.
[11] to soft-update the target-network parameter and the
Q avg value,
[Equation]
Soft-updates are performed after each iteration.
Warm-start step.
We follow Kumar et al.
[45] and Yue et al.
[88] to warm-start our policy training in the first N warm epochs.
In this step, the policy is optimized w.r.t.
the generator loss L g ( ϕ ) only, i.e. , arg min ϕ
L g ( ϕ ) .
The learning rate η ϕ in the warm-start step is the same as the normal training step.
E.2 Details for the continuous-control experiment
Datasets.
We evaluate algorithms on the continuous control tasks in the D4RL benchmark [31].
Due to limited computational resources, we select therein a representative set of datasets.
Specifically, (1) we select the “medium-expert,” “medium-replay,” and “medium” datasets for the Hopper, HalfCheetah, and Walker2d tasks in the Gym-MuJoCo domain, which are commonly used benchmarks in prior work [12, 13, 89, 45].
As in recent literature [21, 90, 91], we do not test on the “random” and “expert” datasets, as they are considered as less practical [84] and can be simply solved by directly applying standard off-policy RL algorithms [14] and behavior cloning on the offline dataset.
We note that a data-quality agnostic setting may not align with practical offline RL applications, i.e. , one typically should know the quality of the offline datasets, e.g. , whether it is collected by random policy or by experts.
(2) Apart from the Gym-MuJoCo domain, we further consider the Maze2D domain of tasksfor the non-Markovian data-collecting policy and the Adroit tasks 3 [92] for their high dimensionality and sparse rewards.
Evaluation protocol.
Our algorithm is trained for 1000 epochs, where each epoch consists ofmini-batch gradient descent steps.
After each epoch of training, a rollout of 10 episodes is performed.
Both our algorithm and baselines are run under five random seeds { 0 , 1 , 2 , 3 , 4 } , and we report the mean and standard deviation of the final rollouts across the five seeds.
We follow Fu et al. [31] to rerun the baselines under the recommended hyperparameter setting, including dataset-specific hyperparameters if available.
Results of CQL.
We run CQL using the implementation suggested by Kostrikov et al.
[91], which only provide hyperparameters for the Gym-MuJoCo and AntMaze domains.
For the Maze2D and
Adroit datasets, we run both sets of recommended hyperparameters and per-dataset select the better result to report.
We note that hyperparameter settings for the Maze2D and Adroit datasets are also not provided in the original CQL implementation.
An in-depth tuning of CQL on these two domains of datasets is beyond the scope of this paper.
Implicit policy implementation.
We follow White [93] to choose the noise distribution as the isotropic normal, i.e. , p z ( z ) ≜ N (cid:0) 0 , σ 2noise I (cid:1) , where the default setting of the dimension of z is dim ( z ) = min ( 10 , state _ dim // 2 ) and of the noise standard deviation is σ noise = 1 .
In the forward pass of the implicit policy, for a given state s , a noise sample z ∼ p
z ( z ) is first independently drawn.
Then s is concatenated with z and the resulting [ s, z ] is inputted into the (deterministic) policy network to sample stochastic action.
Terminal states.
In practice, the episodes in the offline dataset have finite horizon.
Thus, special treatment is needed for those terminal states in calculating the Bellman update target.
We combine common practice [94, 95] with our critic update target Eq.
(25) as
[Equation]
if s ′ is a non-terminal state
[Equation]
if s ′ is a terminal state , since the action-value function is undefined on the terminal s ′ due to no action choice therein.
Our network architecture is presented in Appendix E.2.1.
To save computation, we use simple neural networks as in Fujimoto et al.
A fine-tuning of the noise distribution p z ( z ) , the network architecture, the optimizer hyperparameters, etc. , is left for future work.
E.2.1 Details for the implementation of AMPL
With the training techniques for GAN suggested by previous work in generative modeling, we are able to stably and effectively train the GAN structure on data with moderate dimension, e.g. , the
D4RL datasets we consider.
In this paper, we adopt the following techniques from the literature.
• Following Goodfellow et al.
[35], π ϕ is trained to maximize E ( s,a ) ∈B fake [log ( D ψ ( s, a ))] .
• We are motivated by Radford et al.
[96] to use LeakyReLU activation function in both the generator and the discriminator, with negative_slope being the default value 0 .
• For stable training, we follow Radford et al.
[96] to use a reduced momentum term β 1 = 0 .in
the Adam optimizers of the policy and the discriminator networks; and to use learning rates η ϕ = η ψ = 2 × 10 − 4 .
• To avoid discriminator overfitting, we are motivated by Salimans et al.
[97] and Goodfellow [98] to use one-sided label smoothing with soft and noisy labels.
Specifically, random numbers in [0 . 8 , 1 . 0) are used as the labels for the “true” sample B true .
No label smoothing is needed for the “fake” sample B fake , i [Table] e. , their labels are all 0 .
• Binary cross entropy loss between the labels and the discriminator outputs is used as the loss for the discriminator training in the underlying GAN structure.
• We are motivated by TD3 [11] and GAN to update the policy π ϕ ( · | s ) once per k updates of the critics and the discriminator.
Table 5 shows the shared hyperparameters for all datasets in our experiments.
Many of these hyperparameters follow the literature without further tuning .
For example, we use η ϕ = η ψ = 2 × 10 − 4 as in Radford et al.
[96], η θ = 3 × 10 − 4 and N warm = 40 as in Kumar et al.
[45], c = 0 .as in Fujimoto et al [Table]
[12], policy frequency k = 2 as in Fujimoto et al.
[11], f = 0 .
5 as in Yu et al. [18] and model learning rate η (cid:98) P = 0 .
001 as in Yu et al.
Unless specified, the shared and the non-shared hyperparameters are used throughout the main results and the ablation study [Table] [Table]
[Table]
Since the tested datasets possess diverse nature, we follow the common practice in offline model-based
RL to perform gentle dataset-specific hyperparameter tuning.
Details are discussed below.
We are motivated by Janner et al.
[15] and Yu et al.
[16] to consider the rollout horizon h ∈ { 1 , 3 , 5 } .
We use h = 1 for halfcheetah-medium, hopper-medium, hopper-medium-replay, maze2dlarge, pen-expert, door-expert, pen-human; h = 3 for hopper-medium-expert, walker2d-medium, halfcheetah-medium-replay, maze2d-umaze, maze2d-medium; and h = 5 for halfcheetah-mediumexpert, walker2d-medium-expert, walker2d-medium-replay, pen-cloned.
Zheng and Zhou [99] and Zhang et al.
[100] show that a larger noise dimension, e.g. , 50 , can help learning a more flexible distribution, while a smaller noise dimension, e.g. , 1 , can make the distribution leaning towards deterministic.
Hence we use the default noise dimension for the tasks: maze2d-umaze, door-expert; noise dimension 50 for the tasks: hopper-medium-expert, halfcheetahmedium-expert, walker2d-medium-expert, halfcheetah-medium, hopper-medium, walker2d-medium, halfcheetah-medium-replay, hopper-medium-replay, walker2d-medium-replay, maze2d-medium, maze2d-large, pen-expert; and noise dimension 1 for the tasks: pen-cloned, pen-human.
Due to the narrow data distribution, we use σ noise = 0 .
001 for datasets pen-human and pen-cloned to avoid training divergence.
We state below the network architectures of actor, critic, discriminator, and MIW in the implementation of AMPL.
Motivated by the clipped double Q-learning, two critic networks are used with the same architecture.
[Table]
In the MIW network, α is the smoothing exponent to smooth the distribution of the weight estimates in the offline dataset, whose design is motivated by Hishinuma and Senda [47].
We fix α as 0 .
5 on the MuJoCo datasets and as 0 .
2 on the Maze2D and Adroit datasets.
The output of the MIW network prior to power ( α ) is lower bounded by 10 − 8 to avoid gradient explode.
We follow Dai et al.
[69] to initialize the weights of last layer of the MIW network from Uniform ( − 0 .
003 , 0 . 003) , and bias as 0 .
E.3 Details for the implementation of alternative MIW estimation methods in Section [-4.
-]4.
We implement and train the alternative methods VPM, GenDICE, and DualDICE in Section 4. based on the corresponding papers and source codes.
To stabilize training, the design of target MIW network in Section E.1.2 is applied wherever applicable.
The target MIW network is hard-updated, as suggested by the corresponding papers.
The ν network in GenDICE and DualDICE has the same architecture as the critic network and has its own hard-updated target network.
We follow the official implementation of GenDICE and DualDICE to clip the gradient values by 1 .
For the convex function f in DualDICE, we use f ( x ) =
| x | 3 / 2 , as suggested in its Section 5.3.
F Potential negative societal impacts
Since offline RL has strong connection with the supervised learning, offline RL methods, including the proposed AMPL in this paper, are subject to the bias in the offline dataset.
The data-bias can be exploited by both the dynamic-model learning and the policy training.
G Computing resources
We ran all experiments on 4 NVIDIA Quadro RTX 5000 GPUs.