[ Unity ] 유니티 ML-agents 예제 실행 방법.
https://unity.com/kr/products/machine-learning-agents
머신러닝 에이전트
심층 학습 기술을 활용하는 툴킷으로 지능적인 반응형 에이전트를 만들어 보세요.
unity.com
https://github.com/Unity-Technologies/ml-agents
GitHub - Unity-Technologies/ml-agents: The Unity Machine Learning Agents Toolkit (ML-Agents) is an open-source project that enab
The Unity Machine Learning Agents Toolkit (ML-Agents) is an open-source project that enables games and simulations to serve as environments for training intelligent agents using deep reinforcement ...
github.com
https://pytorch.kr/get-started/previous-versions/
파이토치 한국 사용자 모임 (PyTorch Korea User Group)
파이토치 한국 사용자 모임에 오신 것을 환영합니다. 딥러닝 프레임워크인 파이토치(PyTorch)를 사용하는 한국어 사용자들을 위해 문서를 번역하고 정보를 공유하고 있습니다.
pytorch.kr
ML-agent를 설치하면서 생기는 오류는 대부분 버전 관련 오류인 거 같고 저도 오류를 해결하는데 꾀많은 시간이 소요되었습니다.
제 환경을 사진으로 올려드릴 테니 확인하시고 동일한 버전으로 진행해야 오류가 안 생깁니다.
ml-agents == 0.29.0
PyTorch == 1.6.0
Python == 3.7.16
torchvision == 0.7.0
위 github 주소에서 ml-agents 예제 파일을 다운받아 줍니다.
Anaconda Prompt를 기준으로 작업합니다.
새로운 가상환경을 하나 만들어 줍니다.
conda create -n unityml(아무이름) python = 3.7
conda activate unityml(가상환경이름)
cd 명령어를 사용해서 github에서 다운받은 예제 파일 주소로 이동해줍니다.
PyTorch 와 Torchvision 도 다운받아 줍니다.
맨위 파이토치 한국 사용자모임 에서 다른버전도 다운받을수 있습니다.
conda install pytorch==1.6.0 torchvision==0.7.0 cpuonly -c pytorch
pip install -e ./ml-agents-envs
pip install -e ./ml-agents
pip install mlagents or pip install mlagents=0.29.0
파이토치, 토치비전, mlagents 를 모두 다운받고
mlagents-learn을 입력하면 유니티 로고가 나오게됩니다.
이제 예제 Hallway를 한번 실행시켜보고 학습시켜 보겠습니다.
예제는
Assets -> ML-Agents -> Examples -> Hallway -> Scenes를 열어주면 됩니다.
유니티 예제에 내장되어있는 모델로 실행시킨 경우 입니다.
이제 직접 학습 시키려면
Behavior Parameters 에서 Model을 제거해주고.
프로젝트 폴더에 yaml 파일 주소를 복사해 줍니다.
다시 anaconda prompt에와서.
mlagents-learn "D:\ml-agents-release_21\config\ppo\Hallway.yaml" --run-id=test(이름) 를 입력해줍니다.
이미 실행한적이 있는경우. 이어서 학습하기.
mlagents-learn "D:\ml-agents-release_21\config\ppo\Hallway.yaml" --run-id=test(이름) --resume
기존 파일이 있지만 처음부터 다시 학습하기.
mlagents-learn "D:\ml-agents-release_21\config\ppo\Hallway.yaml" --run-id=test(이름) --force
이제 유니티 플레이 버튼을 누르게 되면.
이런식으로 학습이되고 학습 진행과정을 볼수 있습니다.