docs.unity3d.com
  • Manual
  • Scripting API
  • Changelog
  • License
ML Agents 2.2.1-exp.1
  • 3.0 2023.2+
  • 2.3 2020.3+
  • 2.1 2019.4+
  • 2.0 2019.4+
  • 1.9 2018.4+
  • 1.8 2018.4+
  • 1.7 2018.4+
  • 1.6 2018.4+
  • 1.5 2018.4+
  • 1.4 2018.4+
  • 1.3 2018.4+
  • 1.2 2018.4+
  • 1.1 2018.4+
  • 1.0 2018.4+
    • Manual

    About ML-Agents package (com.unity.ml-agents)

    The ML-Agents package contains the primary C# SDK for the Unity ML-Agents Toolkit.

    The package allows you to convert any Unity scene into a learning environment and train character behaviors using a variety of machine learning algorithms. Additionally, it allows you to embed these trained behaviors back into Unity scenes to control your characters. More specifically, the package provides the following core functionalities:

    • Define Agents: entities, or characters, whose behavior will be learned. Agents are entities that generate observations (through sensors), take actions, and receive rewards from the environment.
    • Define Behaviors: entities that specify how an agent should act. Multiple agents can share the same Behavior and a scene may have multiple Behaviors.
    • Record demonstrations of an agent within the Editor. You can use demonstrations to help train a behavior for that agent.
    • Embedding a trained behavior into the scene via the Unity Inference Engine. Embedded behaviors allow you to switch an Agent between learning and inference.

    Note that the ML-Agents package does not contain the machine learning algorithms for training behaviors. The ML-Agents package only supports instrumenting a Unity scene, setting it up for training, and then embedding the trained model back into your Unity scene. The machine learning algorithms that orchestrate training are part of the companion Python package.

    Note that we also provide an ML-Agents Extensions package (com.unity.ml-agents.extensions) that contains early/experimental features that you may find useful. This package is only available from the ML-Agents GitHub repo.

    Package contents

    The following table describes the package folder structure:

    Location Description
    Documentation~ Contains the documentation for the Unity package.
    Editor Contains utilities for Editor windows and drawers.
    Plugins Contains third-party DLLs.
    Runtime Contains core C# APIs for integrating ML-Agents into your Unity scene.
    Runtime/Integrations Contains utilities for integrating ML-Agents into specific game genres.
    Tests Contains the unit tests for the package.

    Installation

    To install this ML-Agents package, follow the instructions in the Package Manager documentation.

    To install the companion Python package to enable training behaviors, follow the installation instructions on our GitHub repository.

    Advanced Installation

    With the changes to Unity Package Manager in 2021, experimental packages will not show up in the package list and have to be installed manually. There are two recommended ways to install the package manually:

    Github via Package Manager

    In Unity 2019.4 or later, open the Package Manager, hit the "+" button, and select "Add package from git URL".

    Package Manager git URL

    In the dialog that appears, enter

    git+https://github.com/Unity-Technologies/ml-agents.git?path=com.unity.ml-agents#release_19
    

    You can also edit your project's manifest.json directly and add the following line to the dependencies section:

    "com.unity.ml-agents": "git+https://github.com/Unity-Technologies/ml-agents.git?path=com.unity.ml-agents#release_19",
    

    See Git dependencies for more information. Note that this may take several minutes to resolve the packages the first time that you add it.

    Local Installation for Development

    Clone the repository and follow the Local Installation for Development directions.

    Requirements

    This version of the Unity ML-Agents package is compatible with the following versions of the Unity Editor:

    • 2019.4 and later

    Known Limitations

    Training

    Training is limited to the Unity Editor and Standalone builds on Windows, MacOS, and Linux with the Mono scripting backend. Currently, training does not work with the IL2CPP scripting backend. Your environment will default to inference mode if training is not supported or is not currently running.

    Inference

    Inference is executed via the Unity Inference Engine.

    CPU

    All platforms supported.

    GPU

    All platforms supported except:

    • WebGL and GLES 3/2 on Android / iPhone

    NOTE: Mobile platform support includes:

    • Vulkan for Android
    • Metal for iOS.

    Headless Mode

    If you enable Headless mode, you will not be able to collect visual observations from your agents.

    Rendering Speed and Synchronization

    Currently the speed of the game physics can only be increased to 100x real-time. The Academy also moves in time with FixedUpdate() rather than Update(), so game behavior implemented in Update() may be out of sync with the agent decision making. See Execution Order of Event Functions for more information.

    You can control the frequency of Academy stepping by calling Academy.Instance.DisableAutomaticStepping(), and then calling Academy.Instance.EnvironmentStep()

    Unity Inference Engine Models

    Currently, only models created with our trainers are supported for running ML-Agents with a neural network behavior.

    Helpful links

    If you are new to the Unity ML-Agents package, or have a question after reading the documentation, you can checkout our GitHub Repository, which also includes a number of ways to connect with us including our ML-Agents Forum.

    In order to improve the developer experience for Unity ML-Agents Toolkit, we have added in-editor analytics. Please refer to "Information that is passively collected by Unity" in the Unity Privacy Policy.


    Did you find this page useful? Please give it a rating:

  • Thanks for rating this page!

    Report a problem on this page

    What kind of problem would you like to report?

    • This page needs code samples
    • Code samples do not work
    • Information is missing
    • Information is incorrect
    • Information is unclear or confusing
    • There is a spelling/grammar error on this page
    • Something else

    Thanks for letting us know! This page has been marked for review based on your feedback.

    If you have time, you can provide more information to help us fix the problem faster.

    Provide more information

    You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:

    You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:

    You've told us there is information missing from this page. Please tell us more about what's missing:

    You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:

    You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:

    You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:

    You've told us this page has a problem. Please tell us more about what's wrong:

    Thank you for helping to make the Unity documentation better!

    Your feedback has been submitted as a ticket for our documentation team to review.

    We are not able to reply to every ticket submitted.

    In This Article
    • Package contents
    • Installation
      • Advanced Installation
    • Requirements
    • Known Limitations
      • Training
      • Inference
      • Headless Mode
      • Rendering Speed and Synchronization
      • Unity Inference Engine Models
    • Helpful links
    Back to top
    Terms of use
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023
    By clicking “Accept Cookies”, you agree to the storing of cookies on your device to enhance site navigation, analyze site usage, and assist in our marketing efforts.
    Company Logo

    Privacy Preference Center

    Your Opt Out Preference Signal is Honored
    • Your Privacy

    • Functional Cookies

    • Performance Cookies

    • Targeting Cookies

    • Strictly Necessary Cookies

    Your Privacy

    When you visit any website, it may store or retrieve information on your browser, mostly in the form of cookies. This information might be about you, your preferences or your device and is mostly used to make the site work as you expect it to. The information does not usually directly identify you, but it can give you a more personalized web experience. Because we respect your right to privacy, you can choose not to allow some types of cookies. Click on the different category headings to find out more and change our default settings. However, blocking some types of cookies may impact your experience of the site and the services we are able to offer.
    More information

    Functional Cookies

    Active

    These cookies enable the website to provide enhanced functionality and personalisation. They may be set by us or by third party providers whose services we have added to our pages. If you do not allow these cookies then some or all of these services may not function properly.

    Performance Cookies

    Active

    These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us to know which pages are the most and least popular and see how visitors move around the site. All information these cookies collect is aggregated and therefore anonymous. If you do not allow these cookies we will not know when you have visited our site, and will not be able to monitor its performance.

    Targeting Cookies

    Active

    These cookies may be set through our site by our advertising partners. They may be used by those companies to build a profile of your interests and show you relevant adverts on other sites. They do not store directly personal information, but are based on uniquely identifying your browser and internet device. If you do not allow these cookies, you will experience less targeted advertising. Some 3rd party video providers do not allow video views without targeting cookies. If you are experiencing difficulty viewing a video, you will need to set your cookie preferences for targeting to yes if you wish to view videos from these providers. Unity does not control this.

    Strictly Necessary Cookies

    Always Active

    These cookies are necessary for the website to function and cannot be switched off in our systems. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms. You can set your browser to block or alert you about these cookies, but some parts of the site will not then work. These cookies do not store any personally identifiable information.

    Cookie List

    Consent Leg.Interest
    label
    label
    label
      label
      Powered by Onetrust