Videos

How to use Machine Learning AI in Unity! (ML-Agents)



Code Monkey

🌍 Let’s learn how to get started unlocking the POWER of Machine Learning AI in Unity!
📦 Unity Machine Learning Playlist: https://www.youtube.com/playlist?list=PLzDRvYVwl53vehwiN_odYJkPBzcqFw110
🌍 Get my Complete Courses! ✅ https://unitycodemonkey.com/courses
👍 Learn to make awesome games step-by-step from start to finish.

ML-Agents GitHub https://github.com/Unity-Technologies/ml-agents/releases/tag/release_10

Give your feedback on the forums: https://forum.unity.com/forums/ml-agents.453/

00:00 What is Machine Learning, ML-Agents
01:22 Installation (Python, PyTorch, CUDA, ML-Agents)
10:10 New Unity Project

12:00 Create Agent

13:35 Agent Actions

17:21 Test Training

19:46 Agent Observations

24:10 Agent Reward

27:57 Heuristics Testing

29:38 Training

34:22 Use Trained Brain Model
40:04 Improve Brain Model
40:55 TensorBoard Visualization
43:25 Final Result

Teach your AI! Imitation Learning with Unity ML-Agents!
https://www.youtube.com/watch?v=supqT7kqpEI

🌍 Get Code Monkey on Steam!
👍 Interactive Tutorials, Complete Games and More!
https://store.steampowered.com/app/1294220/

If you have any questions post them in the comments and I’ll do my best to answer them.

🔔 Subscribe for more Unity Tutorials https://www.youtube.com/channel/UCFK6NCbuCIVzA6Yj1G_ZqCg?sub_confirmation=1

See you next time!

📍 Support on Patreon https://www.patreon.com/unitycodemonkey
🤖 Join the Community Discord https://discord.gg/eHjUVrm
📦 Grab the Game Bundle at https://unitycodemonkey.com/gameBundle.php
📝 Get the Code Monkey Utilities at https://unitycodemonkey.com/utils.php

#unitytutorial #unity3d #unity2d

——————————————————————–

Hello and welcome, I am your Code Monkey and here you will learn everything about Game Development in Unity 2D using C#.

I’ve been developing games for several years with 7 published games on Steam and now I’m sharing my knowledge to help you on your own game development journey.

You can see my games at www.endlessloopstudios.com

——————————————————————–

– Website: https://unitycodemonkey.com/
– Twitter: https://twitter.com/UnityCodeMonkey
– Facebook: https://www.facebook.com/UnityCodeMonkey/

Source

Similar Posts

44 thoughts on “How to use Machine Learning AI in Unity! (ML-Agents)
  1. Hmmm…. I followed each and every step (ofcouse with a newer version as of right now) and ran the script.
    The console in Unity gives me constantly this message:

    Fewer observations (0) made than vector observation size (6). The observations will be padded.

    What am I doing wrong and how do I solve that?

  2. One of the most ridiculously annoying voices I've ever heard on Youtube. Consider getting someone else to do the voiceovers or get speech therapy

  3. Traceback (most recent call last):

    File "<frozen runpy>", line 198, in _run_module_as_main

    File "<frozen runpy>", line 88, in _run_code

    File "E:OfficeAim_ball_shootvenvScriptsmlagents-learn.exe__main__.py", line 4, in <module>

    File "E:OfficeAim_ball_shootvenvLibsite-packagesmlagentstrainerslearn.py", line 2, in <module>

    from mlagents import torch_utils

    File "E:OfficeAim_ball_shootvenvLibsite-packagesmlagentstorch_utils__init__.py", line 1, in <module>

    from mlagents.torch_utils.torch import torch as torch # noqa

    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

    File "E:OfficeAim_ball_shootvenvLibsite-packagesmlagentstorch_utilstorch.py", line 6, in <module>

    from mlagents.trainers.settings import TorchSettings

    File "E:OfficeAim_ball_shootvenvLibsite-packagesmlagentstrainerssettings.py", line 25, in <module>

    from mlagents.trainers.cli_utils import StoreConfigFile, DetectDefault, parser

    File "E:OfficeAim_ball_shootvenvLibsite-packagesmlagentstrainerscli_utils.py", line 5, in <module>

    from mlagents_envs.environment import UnityEnvironment

    File "E:OfficeAim_ball_shootvenvLibsite-packagesmlagents_envsenvironment.py", line 12, in <module>

    from mlagents_envs.side_channel.side_channel import SideChannel

    File "E:OfficeAim_ball_shootvenvLibsite-packagesmlagents_envsside_channel__init__.py", line 5, in <module>

    from mlagents_envs.side_channel.default_training_analytics_side_channel import ( # noqa

    File "E:OfficeAim_ball_shootvenvLibsite-packagesmlagents_envsside_channeldefault_training_analytics_side_channel.py", line 7, in <module>

    from mlagents_envs.communicator_objects.training_analytics_pb2 import (

    File "E:OfficeAim_ball_shootvenvLibsite-packagesmlagents_envscommunicator_objectstraining_analytics_pb2.py", line 35, in <module>

    _descriptor.FieldDescriptor(

    File "E:OfficeAim_ball_shootvenvLibsite-packagesgoogleprotobufdescriptor.py", line 561, in _new_

    _message.Message._CheckCalledFromGeneratedFile()

    TypeError: Descriptors cannot not be created directly.

    If this call came from a _pb2.py file, your generated code is out of date and must be regenerated with protoc >= 3.19.0.If you cannot immediately regenerate your protos, some other possible workarounds are:

    1. Downgrade the protobuf package to 3.20.x or lower.

    2. Set PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python (but this will use pure-Python parsing and will be much slower).

    More information: https://developers.google.com/protocol-buffers/docs/news/2022-05-06#python-updates

    this is the error i am getting plz help me

  4. Thank you for the great video. After dragging and attaching the MoveToGoalAgent script to the Agent, my inspector got two MoveToGoalAgent(script) instead of one behavior parameter and one MoveToGoalAgent(script). I would appreciate it if you gave me a hint to solve that problem.

  5. Thanks for a greate tutorial! I've been playing with DL and RL for the last year or so (though not very intesively), and it's one of my main objects of interest, especially RL. And it's a greate pleasure to me to finally discover such things as ML-Agents in general, and Unity integration in particular (why didn't I find it before?). Can't even express now what a huge window of possibilites I see now for myself. A huge field of experiments I wanted to do for a long time. And what an awesome way to create my own environments! I just saw that I can even simply just create the envs in Unity, but make the rest of learning separately in Python!

  6. Fantastic tutorial, thank you for all the indepth steps.

    Quick question as you mentioned not bothering with CUDA if you don't have an NVIDIA graphics card and it'll just utilize the CPU instead.

    For those of use with AMD cards, do you know if this toolkit integrates with ROCm or OpenCL?

  7. Hi Code monkey , what are the alternatives to making an ai , i am trying to make an ai for a card game like gin rummy and will unity machine learning ai give same actions under same moves?

  8. I ran into a Traceback error when running "mlagents-learn" @17:40. ('str' object has no attribute '_key') I was able to fix this by installing an older version of the importlib-metadata library: pip install importlib-metadata==4.4

  9. I tried this but I failed at multiple things. First of all, I couldnt find the unity folder right in C: and I ended up using the one in the appdataroaming folder even though there werent any project files in there. Second of all, I placed the virtual environment right in the Unity folder. I was running command prompt as administrator aswell. And i couldnt download the specific version of pytorch. It ended up that i was in my python project without MLagents installed. Just like always

  10. When I started fallowing this tutorial I would get a lot of errors, but I managed to fix those errors, and then I decided to make my own ML-Agents video. It is vary similar to this video but it shows how I fixed all the errors I was getting. For those that want to fallow my tutorial here is a link: https://youtu.be/RANRz9oyzko. But I just wanted to say thank you code monkey for this awesome video. without it I would not have been able to make my video.

  11. After a few days of following your tutorial little by little (sorry I'm still a newbie),, finally I can understand what you teach, even though there are many changes to the ML-Agents.. but thank you so much Mr.hugo for the knowledge this is very useful for me curious about machine learning.

  12. I know this video is from 2years ago but pls help me. When I want to write the "OnCollisionEnter" ( 24:40), I dont get the suggestion and it doesnt work :/. My game is in 2d can this be the problem??

  13. hi codemonkey, thanks for the video, but i need help. i stuck on 6:45, i got an error when i ran mlagents-learn –help. it said
    "TypeError: Invalid first argument to `register()`. typing.Dict[mlagents.trainers.settings.RewardSignalType, mlagents.trainers.settings.RewardSignalSettings] is not a class or union type." if you or anyone else know the solution,the ha help is much appreciated

  14. I'm too dumb for this I tried to follow it all the way but I can't deal with all those errors and hickups constantly, I'll just wait for ML sandboxes to get good GUIs cause all this Python/pip/C#/Unity making my brain hurt

  15. hello! nice tutorial as always but I have a question. It is possible to continue to train the agent in a build environment? I want use it in my game to the players have a personalized experience, so the agent should learn how each player plays the game. tks in advance

  16. Hi from 2023! For whom ever had a problem with pip packages and instaling phyton here is what worked for me lately:
    Unity: 2022.3.10
    Python 3.9.13
    And in venv activated i wrote successively:
    python -m pip install –upgrade pip
    pip install mlagents
    pip3 install torch torchvision torchaudio
    pip install protobuf==3.20.3

    Works for me, cheers!

Comments are closed.

WP2Social Auto Publish Powered By : XYZScripts.com