Unity-Technologies / ml-agents

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 learning and imitation learning.
https://unity.com/products/machine-learning-agents
Other
16.93k stars 4.14k forks source link

How do I train on a mobile device? #2099

Closed smilejsu82 closed 4 years ago

smilejsu82 commented 5 years ago

Hi. I am a developer who is enjoying ml-agent nowadays. I am trying to follow the documentation here. (https://github.com/Unity-Technologies/ml-agents)

I am currently using Windows 10. So I use mlagents-learn config / config.yaml --run-id = -train command in Anaconda Prompt. After the mobile build, I wonder how to start training. Even if I search, I can not find a proper answer and try to write. I saw an article that uses AWS as shown below. I would like to know if this is common. (https://github.com/Unity-Technologies/ml-agents/blob/master/docs/Training-on-Amazon-Web-Service.md)

shihzy commented 5 years ago

hi @smilejsu82 - are you creating a separate build from the Unity scene? if so, you need to specific the env-name parameter for the mlagents-learn call as well.

smilejsu82 commented 5 years ago

Thank you for answer. I have checked the following manuals.

" (Optional) is the name (including path) of your Unity executable containing the agents to be trained."

At this time, I do not know how to set the path for the Android platform.

shihzy commented 5 years ago

hi @smilejsu82 - you should be setting the target build to windows to do the training. once the training is complete, you can put the .nn file back and then build / deploy to android.

smilejsu82 commented 5 years ago

Thank you for answer. As you mentioned, after Windows build, reinforcement learning was possible with the following command.

(ml-agents) D:\workspace\unity\Test\UnitySDK>mlagents-learn trainer_config.yaml --env=C:\Users\smilejsu\Desktop\test-mlagent.exe --run-id=test0 --train

You can also load the generated .nn file and apply it to the agent. But it's still a question. I have not figured out how to train on the mobile platform (android / iOS) yet.

https://smilejsu.tistory.com/1697

Is this possible?

shihzy commented 5 years ago

hi @smilejsu82 - unfortunately we do not enable training on the mobile platform. Can you describe why you are trying to train on a mobile device?

smilejsu82 commented 5 years ago

I am developing games using ml-agent. This game allows the user to train a given character. Every user can train a given character in several ways (reinforcement learning) For example, avoiding the arrows that come in, drinking a potion if you lack physical strength, attacking nearby enemies, etc. We want to create a game that can compete with trained characters on the battlefield. So I want to learn mobile devices.

rsfutch77 commented 5 years ago

Hello,

I am following this thread because my goal is very similar. I wanted to have many different brains all trained to do the same task, but users could end up with different results based on how they train their characters.

My plan right now is to just have the users send their training settings to a server (via interface in a mobile app) and the server actually does the training.

To the user it will seem as though they are training the character on their mobile device.

shihzy commented 5 years ago

Hello,

I am following this thread because my goal is very similar. I wanted to have many different brains all trained to do the same task, but users could end up with different results based on how they train their characters.

My plan right now is to just have the users send their training settings to a server (via interface in a mobile app) and the server actually does the training.

To the user it will seem as though they are training the character on their mobile device.

To confirm my understanding - the user of your game is able to select or configure how they want the agent to be trained. Once they select or configure, the game would train the agent in the way the user wants? Could you elaborate more on this?

rsfutch77 commented 5 years ago

Sure. For example, a robot battle arena:

Each user places an AI battle bot with its own brain in an arena. They customize a combination of weapons/sensors/motors on the bot.

Behind the scenes, on a server, a battle is simulated 1000s of times and a neural network is created and sent back to the user.

The user enters a battle with other players. The AI will use its custom NN to path and make decisions about the battle using their unique set of components.

shihzy commented 5 years ago

i see, thank you for the feedback @rsfutch77. Due to the training times, that example might be very difficult to pull off. What you might try to do is train N number of brains based on the possible combinations of weapons, sensors, and motors. Then, when a user selects the combination, during runtime, the game could load the pre-trained brain.

rsfutch77 commented 5 years ago

The goal would be for an infinite number of combinations. Imagine having an amount of points to spread across each battle bot trait/variable. In this simple game, the training time might be similar to some of the examples in the repo. Players would be able to play with old brains while they wait ~15 minutes to train a new brain.

Allow me to provide another example. In this case the user controls the battle bot directly against an AI. I want the AI to learn from the player's behavior and implement a new brain to fight the player as it learns. With thousands of players, the AI would learn very quickly (after starting with some baseline brain). Basically crowd sourced inference training.

The same situation applies where the training is done on a server and the mobile user just receives brain updates as they are finished.

shihzy commented 5 years ago

thanks for additional details @rsfutch77. we've collected the feedback. as we ship more real-time training / on-device training scenarios, we'll reach back out to get additional feedback.

chriselion commented 4 years ago

Thank you for submitting this request. We’ve added it to our internal tracker with the ID MLA-75. I’m going to close this issue for now, but we’ll ping back with any updates

leahcornelius commented 4 years ago

Any news on this?

github-actions[bot] commented 3 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.