Hub 文档
在 Hugging Face 上使用 ML-Agents
加入 Hugging Face 社区
并获得增强的文档体验
开始使用
在 Hugging Face 上使用 ML-Agents
ml-agents
是一个开源工具包,它使 Unity 创建的游戏和模拟能够作为训练智能代理的环境。
在 Hub 中探索 ML-Agents
您可以通过在模型页面左侧进行筛选来找到 ml-agents
模型。
Hub 上的所有模型都具有有用的功能
- 自动生成的模型卡片,其中包含描述、训练配置等信息。
- 有助于发现的元数据标签。
- Tensorboard 摘要文件,用于可视化训练指标。
- Spaces 网络演示的链接,您可以在其中可视化您的代理在浏览器中运行。

安装库
要安装 ml-agents
库,您需要克隆仓库
# Clone the repository
git clone https://github.com/Unity-Technologies/ml-agents
# Go inside the repository and install the package
cd ml-agents
pip3 install -e ./ml-agents-envs
pip3 install -e ./ml-agents
使用现有模型
您可以使用 mlagents-load-from-hf
轻松地从 Hub 下载模型。
mlagents-load-from-hf --repo-id="ThomasSimonini/MLAgents-Pyramids" --local-dir="./downloads"
您需要定义两个参数
--repo-id
:您要下载的 Hugging Face 仓库的名称。--local-dir
:下载模型的路径。
可视化代理的运行
您可以轻松地在浏览器中直接观看任何模型的运行
- 转到您的模型仓库。
- 在
观看您的代理运行
部分,点击链接。 - 在演示的步骤 1 中,选择您的模型仓库,即模型 ID。
- 在步骤 2 中,选择您要回放的模型。
分享您的模型
您可以使用 mlagents-push-to-hf
轻松上传您的模型
mlagents-push-to-hf --run-id="First Training" --local-dir="results/First Training" --repo-id="ThomasSimonini/MLAgents-Pyramids" --commit-message="Pyramids"
您需要定义四个参数
--run-id
:训练运行 ID 的名称。--local-dir
:模型保存的位置。--repo-id
:您要创建或更新的 Hugging Face 仓库的名称。它是<您的 huggingface 用户名>/<仓库名称>
。--commit-message
.