NeurIPS 2020

摘要

Multi-task learning is a very challenging problem in reinforcement learning. While training multiple tasks jointly allow the policies to share parameters across different tasks, the optimization problem becomes non-trivial: It remains unclear what parameters in the network should be reused across tasks, and how the gradients from different tasks may interfere with each other. Thus, instead of naively sharing parameters across tasks, we introduce an explicit modularization technique on policy representation to alleviate this optimization issue. Given a base policy network, we design a routing network which estimates different routing strategies to reconfigure the base network for each task. Instead of directly selecting routes for each task, our task-specific policy uses a method called soft modularization to softly combine all the possible routes, which makes it suitable for sequential tasks. We experiment with various robotics manipulation tasks in simulation and show our method improves both sample efficiency and performance over strong baselines by a large margin. Our project page with code is at https: //rchalyang.github.io/SoftModule/.

多任务学习是强化学习中一个非常具有挑战性的问题。虽然多个任务的联合训练允许策略在不同的任务中共享参数,但优化问题变得非同小可:网络中的哪些参数应该在不同的任务中重复使用,以及来自不同任务的梯度可能会相互干扰,这些仍不清楚。因此,我们不是简单地在不同任务间共享参数,而是在策略表示上引入明确的模块化技术来缓解这一优化问题。给定一个基础策略网络,我们设计一个路由网络,估计不同的路由策略来为每个任务重新配置基础网络。我们的特定任务策略不是直接为每个任务选择路线,而是使用一种叫做软模块化的方法来软性组合所有可能的路线,这使得其适合于连续的任务。我们在模拟中对各种机器人操作任务进行了实验,结果表明我们的方法比强大的基线在采样效率和性能上都有很大的提高。

研究动机

  • 多任务优势:在不同任务间共享、复用模块,以提高采样效率;提供了一种天然的课程学习,共享参数使简单任务可以帮助困难任务的学习
  • 多任务困难:不清楚任务之间如何相互影响,对一些任务的优化可能对其他任务造成负面干扰
  • 分层强化学习HRL弊端:上层策略和下层策略的同时优化问题;需要提前对子任务进行定义,或使用某些方法去发现子任务

主要贡献

  • 提出一种软模块化方法来自动为每个任务构建模块组合,而不需要HRL的显式策略结构,完全端到端的训练
  • 在MTRL任务中,采样效率和最终性能都得到提升

方法描述

  • 由于软组合过程是可区分的,因此Policy Network和Routing Network可以端到端一起训练。

SAC框架

  • 网络结构

    • 观测表征:$f(s_t)$;任务表征:$h(z_\mathcal{T})$
    • Routing Network

      • $p^l$输出第$l$层$n$个模块到第$l+1$层$n$个模块的概率,维度为$n \times n$
      • $p^{1}=\operatorname{SoftMax}\left[\mathcal{W}_{d}^{1}\left(\operatorname{ReLU}\left(f\left(s_{t}\right) \cdot h\left(z_{\mathcal{T}}\right)\right)\right) \right]$
      • $p^{l+1}=\operatorname{SoftMax}\left[\mathcal{W}_{d}^{l}\left(\operatorname{ReLU}\left(\mathcal{W}_{u}^{l} p^{l} \cdot\left(f\left(s_{t}\right) \cdot h\left(z_{\mathcal{T}}\right)\right)\right)\right)\right]$
      • $\operatorname{SoftMax}$为第$l+1$层模块$i$对第$l$层所有模块的概率和为1
    • Base Policy Network

      • $g_{i}^{l+1}=\sum_{j=1}^{n} \hat{p}_{i, j}^{l}\left(\operatorname{ReLU}\left(W_{j}^{l} g_{j}^{l}\right)\right)$
      • $\mu, \sigma = \sum_{j=1}^n W_j^Lg_j^L$
    • Q-function网络使用相同的结构,不进行参数共享
  • 网络训练

    • Balance平衡不同任务的学习过程:不同任务SAC对应的温度$\alpha_i$不同,策略熵越小温度值越大
    • 总loss为各任务loss加权和,权重表示为:$w_i = \frac{\exp(-\alpha_i)}{\sum_{j=1}^M\exp(-\alpha_j)}$

      • $J_\pi(\phi) = \mathbb{E}_{\mathcal{T} \sim p(\mathcal{T})}[w_\mathcal{T} \cdot J_{\pi,\mathcal{T}}(\phi)]$
      • $J_Q(\theta) = \mathbb{E}_{\mathcal{T} \sim p(\mathcal{T})}[w_\mathcal{T} \cdot J_{Q,\mathcal{T}}(\theta)]$

理论分析

实验验证

  • 实验环境:

    • Meta-World:包含50个机械臂连续控制MuJoCo环境
  • Baseline:

    • Single-task SAC:每个任务独立学习
    • Multi-task SAC (MT-SAC):one-hot任务编码和状态同时作为输入
    • Multi-task multi-head SAC (MT-MH-SAC):每个任务有独立的头作为输出
    • Mixture of Experts (Mix-Expert):四个专家MT-SAC网络,然后使用gating网络进行组合
    • Hard Routing:4层4模块网络,每个任务每层选择1个模块
  • 实验分析

    • routing sharing

routing sharing

  • t-SNE 可视化:每个任务sample多次,将routing weight的$(l-1)n^2=48$维的数据降维表示

t-SNE 可视化

  • 定量实验结果

定量实验结果

  • 参数量

参数量

  • 与Single-task SAC相比:其他任务的数据可以帮助独立任务的训练
  • 消融实验

    • Balance的作用(平衡不同任务的学习进度):在SM中很有效,但在MT-MH框架中无效果
    • 观测编码对于Routing Network的有效性

消融实验

其他思考

  • 本文的思路其实非常简单,利用Soft Modularization实现隐式的任务模块共享。
  • Soft Modularization & Soft Attention(个人理解)

    • 整体模型可以抽象为多层Multi-Head Soft Attention
    • Q: $h(z_\mathcal{T})$;K: $f(s_t)$;V: $g_i^l$

Soft Attention

  • 讨论为什么平衡不同任务的学习进度如此有效。

    • 直观的例子是部分任务存在递进关系(人为理解层面),例如先学习Reach和Push动作,再学习Window-Close任务(先Reach指定位置(窗户把手处),再向指定方向Push),这也是Curriculum Learning范式的出发点。
    • 当然可能是平衡任务学习进度的理解比较粗浅(文章中解释为简单任务比困难任务的收敛速度更快,故理解为学习进度),但实际是由指定任务Policy的entropy决定,即让已经学到有效策略的任务做出让步,可以继续加大探索其他最优策略,减少冲突。

原文链接:https://proceedings.neurips.cc/paper/2020/file/32cfdce9631d8c7906e8e9d6e68b514b-Paper.pdf

参考资料:https://www.bilibili.com/video/av843112683/ & https://zhuanlan.zhihu.com/p/446326692

Last modification:July 25, 2022
如果觉得我的文章对你有用,请随意赞赏