赛事: 昇腾 Model Agent 模型适配大赛(第二季) 引擎: torch_npu + stable_baselines3 硬件: Ascend 310P / 910B 标签:
npuascendpytorchreinforcement-learningstable-baselines3
ppo-LunarLander-v2 是基于 stable-baselines3 PPO 算法训练的 LunarLander 着陆智能体, 提供 PPO_70/75/84/89/90 五个训练进度 checkpoint(mean_reward 最高 301.34)。 MlpPolicy 策略网络,观测为 8 维(坐标/速度/角度/角速度/触地标志), 输出离散动作(0=不操作, 1=左喷, 2=主喷, 3=右喷)。
| 属性 | 值 |
|---|---|
| 原始模型 | https://huggingface.co/Tunamelon/ppo-LunarLander-v2 |
| 算法 | PPO(stable-baselines3 2.9.0) |
| 环境 | LunarLander-v2(mean_reward 301.34) |
| 输入格式 | 8 维观测 |
| 输出格式 | 离散动作(0=无, 1=左, 2=主, 3=右) |
pip install -r requirements.txt -i https://repo.huaweicloud.com/repository/pypi/simple/⚠️ 本仓库不包含模型权重(交付件仅
inference.py/readme.md/requirements.txt/assets/), 推理前必须先从原始模型仓单独下载权重。
# 1. 下载模型权重(仓库不含权重,必须单独下载)
export HF_ENDPOINT=https://hf-mirror.com
huggingface-cli download Tunamelon/ppo-LunarLander-v2 --local-dir ./ppo-LunarLander-v2
# 2. 运行 NPU 推理(给定观测 → 动作)
python3 inference.py --model_path ./ppo-LunarLander-v2 \
--obs "0,0,0,0,0,0,0,0" --device npu:0 --output inference_result.jsonpython3 inference.py --model_path ./ppo-LunarLander-v2 \
--obs "0,0,0,0,0,0,0,0" --device npu:0 --output inference_result.json预期输出:
[Model Agent] ✅ NPU 设备就绪: Ascend310P3
[Model Agent] ✅ 加载权重: PPO_90.zip
[Model Agent] ✅ 模型加载完成 → npu:0
[Model Agent] ✅ 动作: 0 (0=无,1=左,2=主,3=右), 推理耗时 27528.5ms
[Model Agent] ✅ 结果已保存 → inference_result.json推理结果摘要:
{
"model": "Tunamelon/ppo-LunarLander-v2",
"engine": "torch_npu",
"device": "npu:0",
"observation": [0, 0, 0, 0, 0, 0, 0, 0],
"action": 0,
"inference_time_s": 27.53
}.
├── inference.py # NPU 推理脚本
├── readme.md # 本文件
├── requirements.txt # 依赖清单
└── assets/ # 截图素材本模型由 昇腾 Model Agent 自动完成 NPU 适配:
model.policy.to(device))numpy._core.numeric),需 numpy>=2.0inference.py 支持给定观测直接决策,或环境推演(LunarLander-v2)