Skip to main content
 首页 » 编程设计

python之使用 Tensorflow 在 Windows 10 上为 ML-Agents 设置 Unity3D 机器学习

2025年01月19日26insus

我一直在尝试获取 Machine Learning Setup for ML-Agents Unity 3D 在过去几个小时内启动并运行,但没有成功。

首先我关注了this视频,其中介绍了本 GitHub 中也概述的初始安装存储库。

接下来,我继续观看视频系列的第 2 部分 (here),但是问题从 4:48 分钟开始,我意识到教程使用的是 v 0.2,而我使用的是 v 0.3。

V 0.3 取消了视频中显示的 PPO.ipynb 文件。一切都通过 learn.py 文件完成。

然后我决定尝试并遵循官方的 Unity 安装指南:

https://github.com/Unity-Technologies/ml-agents/blob/master/docs/Getting-Started-with-Balance-Ball.md

然后转到Training with PPO部分,我还没有解决。

问题出在这里:文档指出:

To summarize, go to your command line, enter the ml-agents directory and type:

python3 python/learn.py <env_file_path> --run-id=<run-identifier> --train  

Note: If you're using Anaconda, don't forget to activate the ml-agents environment first.

我尝试运行:

python learn.py ball --run-id=ballBalance --train

但是我收到了如下警告:

File "learn.py", line 9, in from unitytrainers.trainer_controller import TrainerController File "C:\Users****\Downloads\ml-agents-master\python\unitytrainers__init__.py", line 1, in from .buffer import *

我已经尝试解决此错误消息已有一段时间了。似乎确实找到了文件 learn.py,但不知何故没有被正确解释?

learn.py 的前 9 行:

# # Unity ML Agents 
# ## ML-Agent Learning 
 
import logging 
 
import os 
from docopt import docopt 
 
from unitytrainers.trainer_controller import TrainerController 

任何有关如何解决此问题的指导将不胜感激。很乐意在需要时提供更多信息。上述步骤应该会重现我遇到的问题。

请您参考如下方法:

我不完全确定我是否解决了同样的问题。但是在我的错误下的某个地方,它还告诉我关于 learn.py 中的第 9 行。

尽管如此,我还是找到了这个 https://github.com/tensorflow/tensorflow/issues/18503 所以我所做的就是通过执行安装 tensorflow 1.5 版:

pip install --upgrade --ignore-installed tensorflow-gpu==1.5 

之后它确实无误地运行并且训练工作正常。