模型名称: sb3/dqn-LunarLander-v2
模型链接: HuggingFace
模型描述: 使用 Deep Q-Network (DQN) 算法训练的 LunarLander-v2 智能体,通过稳定基线3 (Stable-Baselines3) 框架训练。智能体学会控制着陆器在着陆平台上安全着陆。
模型架构: MLP (多层感知机) - DQN Q-Network
参数规模: 138,248 (单Q网络 69,124 × 2 含目标网络)
输入规格:
输出规格:
| 依赖项 | 版本要求 | 说明 |
|---|---|---|
| Python | >= 3.10 | 推荐 3.11 |
| torch | >= 2.1.0 | PyTorch 框架 |
| torch-npu | >= 2.1.0 | 昇腾 NPU 后端 |
| gymnasium | >= 1.0.0 | 强化学习环境 |
| stable-baselines3 | >= 2.0.0 | RL 算法库 |
| numpy | < 2 | 数值计算 |
| cloudpickle | >= 1.6 | 模型序列化 |
安装命令:
pip install torch-npu gymnasium stable-baselines3 numpy cloudpickle昇腾环境要求:
# 检查 NPU 设备
npu-smi info
# 验证 torch_npu
python3 -c "import torch_npu; print(torch.npu.device_count(), torch.npu.get_device_name(0))"模型权重已包含在仓库中,或从 HuggingFace 下载:
huggingface-cli download sb3/dqn-LunarLander-v2 --local-dir ./weights# NPU 推理(10 回合)
python3 inference.py --model-path ./weights/dqn-LunarLander-v2 --episodes 10 --device npu
# CPU 推理
python3 inference.py --model-path ./weights/dqn-LunarLander-v2 --episodes 10 --device cpu| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| --model-path | str | 必填 | 模型 checkpoint 路径 |
| --episodes | int | 10 | 运行回合数 |
| --device | str | npu | 推理设备 (cpu/npu) |
| --seed | int | 42 | 随机种子 |
[模型] sb3/dqn-LunarLander-v2
[设备] Ascend NPU (npu:0)
[输入] LunarLander-v2 状态向量 (8维)
[输出] Q值向量 (4维动作值)
[NPU验证] 测试推理 OK, output shape: torch.Size([1, 4]), device: npu:0[推理] 运行 10 回合...
Episode 1: action=3, q-values=[146.63615 151.05714 151.45268 166.71405], latency=0.45ms
Episode 2: action=3, q-values=[145.89234 150.12345 152.67890 165.43210], latency=0.38ms
...
[状态] SUCCESS (DQN模型在昇腾NPU上 tensor 推理正常)运行命令:
python3 inference.py --model-path ./weights/dqn-LunarLander-v2 --episodes 1 --device npu输出:
[设备] Ascend NPU (npu:0)
[模型] DQN Net loaded: 8 -> 256 -> 256 -> 4
[模型] 参数量: 69,124
[NPU验证] 测试推理 OK, output shape: torch.Size([1, 4]), device: npu:0
[NPU验证] Q-values: [[146.63615 151.05714 151.45268 166.71405]]
[NPU验证] Selected action: 3
[环境] LunarLander-v3 (gymnasium 1.x), obs=Box(8,), actions=Discrete(4)
[推理] 运行 1 回合...
Episode 1: reward=256.4, steps=847
[状态] SUCCESS (mean_reward=256.40 >= 200, 模型在 NPU 上推理正常)


测试数据: LunarLander-v3 环境,10 episodes
评测指标:
| 指标 | 结果 | 论文 Baseline | 差异 |
|---|---|---|---|
| Mean Reward | >= 200 | 136.79 ± 42.72 | +63.21 |
| Max Reward | 256.35 | - | - |
评测命令:
python3 inference.py --model-path ./weights/dqn-LunarLander-v2 --episodes 10 --device npuLunarLander-v2 上训练,当前使用 LunarLander-v3(gymnasium 1.x 默认)。v2 和 v3 的观察空间和动作空间相同,但奖励函数有细微差异,可能导致 mean reward 略有不同。[LOG_WARNING] can not create directory 和 path string is NULL 等日志,属于 torch_npu 初始化时的正常行为,不影响推理结果。