Isaac Lab 强化学习配置详解:PPO 算法参数指南

简介

学习一下IsaacLab中的一些配置类的说明

RslRlPpoAlgorithmCfg

@configclass
class RslRlPpoAlgorithmCfg:
"""Configuration for the PPO algorithm."""

class_name: str = "PPO"
"""The algorithm class name. Default is PPO."""

num_learning_epochs: int = MISSING
"""The number of learning epochs per update."""

num_mini_batches: int = MISSING
"""The number of mini-batches per update."""

learning_rate: float = MISSING
"""The learning rate for the policy."""

schedule: str = MISSING
"""The learning rate schedule."""

gamma: float = MISSING
"""The discount factor."""

lam: float = MISSING
"""The lambda parameter for Generalized Advantage Estimation (GAE)."""
entropy_coef: float = MISSING
"""The coefficient for the entropy loss."""

desired_kl: float = MISSING
"""The desired KL divergence."""

max_grad_norm: float = MISSING
"""The maximum gradient norm."""

value_loss_coef: float = MISSING
"""The coefficient for the value loss."""

use_clipped_value_loss: bool = MISSING
"""Whether to use clipped value loss."""

clip_param: float = MISSING
"""The clipping parameter for the policy."""

normalize_advantage_per_mini_batch: bool = False
"""Whether to normalize the advantage per mini-batch. Default is False.

If True, the advantage is normalized over the mini-batches only.
Otherwise, the advantage is normalized over the entire collected trajectories.
"""

symmetry_cfg: RslRlSymmetryCfg | None = None
"""The symmetry configuration. Default is None, in which case symmetry is not used."""

rnd_cfg: RslRlRndCfg | None = None
"""The configuration for the Random Network Distillation (RND) module. Default is None,
in which case RND is not used.
"""

这个类是 Isaac Lab 中 PPO 算法的配置类,主要用来控制训练中涉及到的超参数和附加模块。

1. 算法基本信息

  • class_name (str)
    • 默认值:"PPO"
    • 说明:使用的算法名称

2. 学习过程参数

  • num_learning_epochs (int)

    • 说明:每次更新时训练的轮数,决定一次采样数据要在网络上迭代多少次
  • num_mini_batches (int)

    • 说明:每次更新拆分的 mini-batch 数量,影响梯度估计的稳定性和训练速度
  • learning_rate (float)

    • 说明:策略网络的学习率
  • schedule (str)

    • 说明:学习率的调度方式,例如固定(constant)、线性衰减(linear)等

3. 折扣与优势估计

  • gamma (float)

    • 说明:折扣因子,用于未来奖励的折现。取值范围 [0, 1],通常接近 1(如 0.99)
  • lam (float)

    • 说明:GAE(Generalized Advantage Estimation,广义优势估计)的 λ 参数,用于控制 bias 和 variance 的平衡。取值范围 [0, 1],通常为 0.95

4. 损失函数相关参数

  • entropy_coef (float)

    • 说明:熵项系数,用于鼓励策略探索,防止过早收敛
  • desired_kl (float)

    • 说明:期望的 KL 散度阈值,用于自适应学习率调整,防止策略更新过快
  • max_grad_norm (float)

    • 说明:梯度裁剪的最大范数,避免梯度爆炸问题
  • value_loss_coef (float)

    • 说明:Value loss 在总损失中的权重系数
  • use_clipped_value_loss (bool)

    • 说明:是否对 Value function 使用裁剪损失,提高训练稳定性
  • clip_param (float)

    • 说明:PPO 中的裁剪参数 ε,限制策略更新幅度,通常设置为 0.2

5. 优势归一化

  • normalize_advantage_per_mini_batch (bool)
    • 默认值:False
    • 说明:
      • False:在整个采样的 trajectory 上归一化优势函数
      • True:在每个 mini-batch 内单独归一化优势函数
    • 作用:提高数值稳定性,影响训练收敛速度

6. 扩展功能

  • symmetry_cfg (RslRlSymmetryCfg | None)

    • 默认值:None
    • 说明:对称性配置,用于利用环境对称性(例如四足机器人的左右对称性)来提高样本效率。若为 None 则不启用
  • rnd_cfg (RslRlRndCfg | None)

    • 默认值:None
    • 说明:随机网络蒸馏(Random Network Distillation, RND)的配置,用于生成内在探索奖励。若为 None 则不启用

总结

此配置类定义了 PPO 算法的:

  • 核心超参数:学习率、折扣因子、GAE λ、熵系数等
  • 稳定性约束:梯度裁剪、损失裁剪、KL 散度限制、优势归一化
  • 扩展模块:对称性利用、内在探索奖励(RND)

它相当于训练过程中所有关键开关和调节旋钮的集中配置点,通过调整这些参数可以控制训练的收敛速度、稳定性和探索效率。

CMakeLists Eigen FCPX GNU Gazebo Git Interest IsaacLab KDL Life Linux Matrix ODE PPO QoS ROS Ros UML Ubuntu VcXsrv algorithm algorithms axis-angle bode c++ calibration chrome control cpp dB data_struct dots figure gdb git latex launch life linux mac math matlab memory motor moveit operator optimal algorithm python robot robotics ros ros2 rtb simulation stl thread tools twist urdf valgrind velocity vim web work wsl 强化学习 配置类
知识共享许可协议