O2O:Sample Efficient Offline-to-Online Reinforcement Learning

2024-03-08 23:36

本文主要是介绍O2O:Sample Efficient Offline-to-Online Reinforcement Learning,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

IEEE TKDE 2024
paper

Introduction

O2O存在策略探索受限以及分布偏移问题,进而导致在线微调阶段样本效率低。文章提出OEMA算法首先使用离线数据训练乐观的探索策略,然后提出基于元学习的优化方法,减少分布偏移并提高O2O的适应过程。

Method

在这里插入图片描述

optimistic exploration strategy

离线学习方法TD3+BC的行为策略 π e ( s ) \pi_e(s) πe(s)是由目标策略 π ϕ ( s ) \pi_\phi(s) πϕ(s)加上一个正态分布中采样的噪声。文章指出,目标策略被优化靠近离线数据集的保守策略,为了提高目标策略的探索能力,本文提出基于价值不确定性度量的方法:
π e = arg ⁡ max ⁡ π Q ^ U B ( s , π ( s ) ) , s . t . 1 2 ∥ π ϕ ( s ) − π ( s ) ∥ ≤ δ , \begin{aligned}\pi_{e}&=\arg\max_{\pi}\hat{Q}_{\mathrm{UB}}(s,\pi(s)),\\s.t.&\frac{1}{2}\|\pi_{\phi}(s)-\pi(s)\|\le\delta,\end{aligned} πes.t.=argπmaxQ^UB(s,π(s)),21πϕ(s)π(s)δ,
其中 Q ^ U B ( s , π ( s ) ) \hat{Q}_{\mathrm{UB}}(s,\pi(s)) Q^UB(s,π(s))为Q值的近似上界, 用来衡量认知不确定性。上述问题在保证策略约束的同时选择高不确信的动作。

不确信估计采用高斯分布。分布的均值为两个Q网络输出的均值,而方差表示如下:
σ Q ( s , a ) = ∑ i = 1 , 2 1 2 ( Q θ i ( s , a ) − μ Q ( s , a ) ) 2 = 1 2 ∣ Q θ 1 ( s , a ) − Q θ 2 ( s , a ) ∣ . \begin{gathered} \sigma_{Q}(s,a) =\sqrt{\sum_{i=1,2}\frac12(Q_{\theta_{i}}(s,a)-\mu_{Q}(s,a))^{2}} \\ =\frac12\Big|Q_{\theta_1}(s,a)-Q_{\theta_2}(s,a)\Big|. \end{gathered} σQ(s,a)=i=1,221(Qθi(s,a)μQ(s,a))2 =21 Qθ1(s,a)Qθ2(s,a) .
那么 Q ^ U B = μ Q ( s , a ) + β UB σ Q ( s , a ) \hat{Q}_{\mathrm{UB}} =\mu_Q(s,a)+\beta_\text{UB}\sigma_Q(s,a) Q^UB=μQ(s,a)+βUBσQ(s,a) β \beta β控制乐观程度,当取值-1时上式等价于:
Q ^ U B ( s , a ) ∣ β U B = − 1 = μ Q ( s , a ) − σ Q ( s , a ) = 1 2 ( Q θ 1 ( s , a ) + Q θ 2 ( s , a ) ) − 1 2 ∣ Q θ 1 ( s , a ) − Q θ 2 ( s , a ) ∣ = min ⁡ ( Q θ 1 ( s , a ) , Q θ 2 ( s , a ) ) , (9) \begin{aligned} &\hat{Q}_{\mathrm{UB}}(s,a)\Big|_{\beta_{\mathrm{UB}}=-1}=\mu_{Q}(s,a)-\sigma_{Q}(s,a) \\ &\begin{aligned}&=\frac{1}{2}(Q_{\theta_1}(s,a)+Q_{\theta_2}(s,a))-\frac{1}{2}|Q_{\theta_1}(s,a)-Q_{\theta_2}(s,a)|\end{aligned} \\ &=\min(Q_{\theta_{1}}(s,a),Q_{\theta_{2}}(s,a)),& \text{(9)} \end{aligned} Q^UB(s,a) βUB=1=μQ(s,a)σQ(s,a)=21(Qθ1(s,a)+Qθ2(s,a))21Qθ1(s,a)Qθ2(s,a)=min(Qθ1(s,a),Qθ2(s,a)),(9)
而当 β = 1 \beta=1 β=1时等价于 Q ^ U B ( s , a ) ∣ β U B = 1 = max ⁡ ( Q θ 1 ( s , a ) , Q θ 2 ( s , a ) ) , \left.\hat{Q}_\mathrm{UB}(s,a)\right|_{\beta_\mathrm{UB}=1}=\max(Q_{\theta_1}(s,a),Q_{\theta_2}(s,a)), Q^UB(s,a) βUB=1=max(Qθ1(s,a),Qθ2(s,a)),

原问题一种简单的解决方法是使用BC将其转化为无约束问题:
π e naive ( s ) = arg ⁡ max ⁡ π Q ^ UB ( s , π ( s ) ) − λ ∥ π ϕ ( s ) − π ( s ) ∥ \pi_e^\text{naive}{ ( s ) }=\arg\max_{\pi}\hat{Q}_\text{UB}{ ( s , \pi ( s ) ) }-\lambda\|\pi_\phi(s)-\pi(s)\| πenaive(s)=argπmaxQ^UB(s,π(s))λπϕ(s)π(s)
然而,由于目标策略通过策略改进不断更新,这种基于行为克隆的惩罚项无法缩小行为策略和目标策略之间的差距,违反了带约束的原问题。

为了解决该问题,提出在TD3的行为策略上增加一项扰动模型 ξ \xi ξ。行为策略改为
π e ( s ) = π ϕ ( s ) + ξ ω ( s , π ϕ ( s ) ) + ϵ \pi_e(s)=\pi_\phi(s)+\xi_\omega(s,\pi_\phi(s))+\epsilon πe(s)=πϕ(s)+ξω(s,πϕ(s))+ϵ
而对扰动模型的参数最小化下列损失函数
L ( ω ) = − E s ∼ B [ Q ^ U B ( s , π e ( s ) ) ] \mathcal{L}(\omega)=-\mathbb{E}_{s\sim\mathcal{B}}\left[\hat{Q}_{\mathrm{UB}}(s,\pi_e(s))\right] L(ω)=EsB[Q^UB(s,πe(s))]

Meta Adaptation for Distribution Shift Reduction

接着,为了解决在线微调存在的分布偏移问题,采用元学习的方法。具体的,保留两个buffer,Buffer B B B存储离线以及在线所有数据, B r B_r Br存储最新在线数据。

meta training

首先在B上训练策略:
L t r n ( ϕ ) = − E s ∼ B [ Q θ 1 ( s , π ϕ ( s ) ) ] \mathcal{L}_{trn}(\phi)=-\mathbb{E}_{s\sim\mathcal{B}}\left[Q_{\theta_1}\left(s,\pi_\phi(s)\right)\right] Ltrn(ϕ)=EsB[Qθ1(s,πϕ(s))]
然后基于SGD的一次梯度下降得到: ϕ ′ = ϕ − α ∇ ϕ L t r n ( ϕ ) \phi^{\prime}=\phi-\alpha\nabla_{\phi}\mathcal{L}_{trn}(\phi) ϕ=ϕαϕLtrn(ϕ)

meta test

然后利用最新在线数据集测试:
L t s t ( ϕ ′ ) = − E s ∼ B r [ Q θ 1 ( s , π ϕ ′ ( s ) ) ] \mathcal{L}_{tst}(\phi')=-\mathbb{E}_{s\sim\mathcal{B}_r}[Q_{\theta_1}(s,\pi_{\phi'}(s))] Ltst(ϕ)=EsBr[Qθ1(s,πϕ(s))]

meta optimization

最后将上述两个损失函数用下面的元优化目标共同优化
ϕ = arg ⁡ min ⁡ ϕ L t r n ( ϕ ) + β L t s t ( ϕ − α ∇ ϕ L t r n ( ϕ ) ) \phi=\arg\min_\phi\mathcal{L}_{trn}(\phi)+\beta\mathcal{L}_{tst}(\phi-\alpha\nabla_\phi\mathcal{L}_{trn}(\phi)) ϕ=argϕminLtrn(ϕ)+βLtst(ϕαϕLtrn(ϕ))

问题

  1. 原文中在meta optimization中对 ϕ \phi ϕ梯度更新是否修正为:
    ϕ ← ϕ − α ∂ ( L t r n ( ϕ ) + β L t s t ( ϕ − α ∇ ϕ L t r n ( ϕ ) ) ) ∂ ϕ \phi\leftarrow\phi-\alpha\frac{\partial\left(\mathcal{L}_{trn}\left(\phi\right) +\beta\mathcal{L}_{tst}\left(\phi-\alpha\nabla_{\phi}\mathcal{L}_{trn}\left(\phi\right)\right)\right)}{\partial\phi} ϕϕαϕ(Ltrn(ϕ)+βLtst(ϕαϕLtrn(ϕ)))
  2. 基于这个偏导出现的第二个问题。这是源码中元学习的训练过程
# Compute actor losseactor_loss = -self.critic.Q1(state, self.actor(state)).mean()""" Meta Training"""self.actor_optimizer.zero_grad()actor_loss.backward(retain_graph=True)self.hotplug.update(3e-4)"""Meta Testing"""self.beta = max(0.0, self.beta - self.anneal_step)meta_actor_loss = -self.critic.Q1(meta_state, self.actor(meta_state)).mean()weight = self.beta * actor_loss.detach() / meta_actor_loss.detach()meta_actor_loss_norm = weight * meta_actor_lossmeta_actor_loss_norm.backward(create_graph=True)"""Meta Optimization"""self.actor_optimizer.step()self.hotplug.restore()

其中,meta-testing中计算weight以及meta_actor_loss_norm不太明白。按照本人的理解,原文计算 L t s t L_{tst} Ltst ϕ \phi ϕ求偏导:
β ∂ L t s t ( ϕ − α ∇ ϕ L t r n ( ϕ ) ) ∂ ϕ = β ∂ L t s t ( ϕ − α ∇ ϕ L t r n ( ϕ ) ) ∂ ϕ ′ ∂ ϕ ′ ∂ ϕ \frac{\beta{\color{red}\partial}\mathcal{L}_{tst}\left(\phi-\alpha\nabla_{\phi}\mathcal{L}_{trn}\left(\phi\right)\right)}{\partial\phi}=\beta\frac{{\color{red}\partial}\mathcal{L}_{tst}\left(\phi-\alpha\nabla_{\phi}\mathcal{L}_{trn}\left(\phi\right)\right)}{\partial\phi'}\frac{\partial\phi'}{\partial\phi} ϕβLtst(ϕαϕLtrn(ϕ))=βϕLtst(ϕαϕLtrn(ϕ))ϕϕ
中间的偏导自然是由meta-test小节的损失函数所得到的meta_actor_loss。而 β ∂ ϕ ′ ∂ ϕ = β ∂ L t s t ∂ ϕ / ∂ L t s t ∂ ϕ ′ = β ∂ L t r n ∂ ϕ / ∂ L t r n ∂ ϕ ′ \beta\frac{\partial\phi'}{\partial\phi}=\beta\frac{\partial L_{tst}}{\partial\phi}/\frac{\partial L_{tst}}{\partial\phi'}=\beta\frac{\partial L_{trn}}{\partial\phi}/\frac{\partial L_{trn}}{\partial\phi'} βϕϕ=βϕLtst/ϕLtst=βϕLtrn/ϕLtrn就是那个weight。
但这样应该使用从相同的Buffer中获得状态数据,这并未在源码中体现。

可能有误,欢迎指正

这篇关于O2O:Sample Efficient Offline-to-Online Reinforcement Learning的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/788786

相关文章

Deep Learning复习笔记0

Key Concept: Embedding: learned dense, continuous, low-dimensional representations of object 【将难以表示的对象(如图片,文本等)用连续的低维度的方式表示】 RNN: Recurrent Neural Network -> for processing sequential data (time se

论文阅读--Efficient Hybrid Zoom using Camera Fusion on Mobile Phones

这是谷歌影像团队 2023 年发表在 Siggraph Asia 上的一篇文章,主要介绍的是利用多摄融合的思路进行变焦。 单反相机因为卓越的硬件性能,可以非常方便的实现光学变焦。不过目前的智能手机,受制于物理空间的限制,还不能做到像单反一样的光学变焦。目前主流的智能手机,都是采用多摄的设计,一般来说一个主摄搭配一个长焦,为了实现主摄与长焦之间的变焦,目前都是采用数字变焦的方式,数字变焦相比于光学

GIM: Learning Generalizable Image Matcher From Internet Videos

【引用格式】:Shen X, Yin W, Müller M, et al. GIM: Learning Generalizable Image Matcher From Internet Videos[C]//The Twelfth International Conference on Learning Representations. 2023. 【网址】:https://arxiv.or

点云处理中阶 Sample Consensus(二)

目录 一、深入理解RSNSAC 二、RANSAC的缺点 三、PCL中常用的Sample Consensus 算法 四、参考资料 一、深入理解RSNSAC RANSAC是“RANdom SAmple Consensus”(随机抽样共识或采样一致性)的缩写,它是一种迭代方法,用于从包含异常值的一组数据中估计数学模型的参数。该算法由Fischler和Bolles于1981年发布。

5.How Fast Should You Be When Learning?(你应该用多快的速度学习? (一))

Normally when I talk about learing quickly, I’m using speed as a synonym for efficiency.Use more effective methods and you’ll learn more in less time.All else being equal, that means you’re learing fa

【Deep Learning】Meta-Learning:训练训练神经网络的神经网络

元学习:训练训练神经网络的神经网络 本文基于清华大学《深度学习》第12节《Beyond Supervised Learning》的内容撰写,既是课堂笔记,亦是作者的一些理解。 1 Meta-Learning 在经典监督学习中,给定训练数据 { ( x i , y i ) } i \{(x_i,y_i)\}_i {(xi​,yi​)}i​,我们需要训练一个神经网络 f f f使得 f (

【Deep Learning】Self-Supervised Learning:自监督学习

自监督学习 本文基于清华大学《深度学习》第12节《Beyond Supervised Learning》的内容撰写,既是课堂笔记,亦是作者的一些理解。 在深度学习领域,传统的监督学习(Supervised Learning)的形式是给你输入 x x x和标签 y y y,你需要训练一个基于参数 θ \theta θ的神经网络 f θ ( x ) f_\theta(x) fθ​(x)使其能

Representation Learning on Network 网络表示学习笔记

Embedding Nodes Encoder-decoder ViewEncoding Methods 1 Factorization based2 Random Walk based3 Deep Learning based 网络表示学习(Representation Learning on Network),一般说的就是向量化(Embedding)技术,简单来说,就是

AI播客下载:Machine Learning Street Talk(AI机器学习)

该频道由 Tim Scarfe 博士、Yannic Kilcher 博士和 Keith Duggar 博士管理。 他们做了出色的工作,对每个节目进行了彻底的研究,并与机器学习行业中一些受过最高教育、最全面的嘉宾进行了双向对话。 每一集都会教授一些新内容,并且提供未经过滤、毫不掩饰的技术对话。 他们列出的人工智能研究人员名单令人印象深刻,他们总是能提供有趣的对话。 之前的一些嘉宾包括 Je

android (No cached version available for offline mode)----bug解析处理

错误日志 Execution failed for task ':base:generateDebugRFile'.> Could not resolve all files for configuration ':base:debugCompileClasspath'.> Could not download core-1.3.0.aar (androidx.core:core:1.3.0)