Unity 机器学习代理工具包 (ML-Agents) 是一个开源项目,它使游戏和模拟能够作为训练智能代理的环境。
您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 
 

2.2 KiB

Using TensorFlowSharp in Unity (Experimental)

The ML-Agents toolkit allows you to use pre-trained TensorFlow graphs inside your Unity games. This support is possible thanks to the TensorFlowSharp project. The primary purpose for this support is to use the TensorFlow models produced by the ML-Agents toolkit's own training programs, but a side benefit is that you can use any TensorFlow model.

Notice: This feature is still experimental. While it is possible to embed trained models into Unity games, Unity Technologies does not officially support this use-case for production games at this time. As such, no guarantees are provided regarding the quality of experience. If you encounter issues regarding battery life, or general performance (especially on mobile), please let us know.

Supported devices

  • Linux 64 bits
  • Mac OS X 64 bits
  • Windows 64 bits
  • iOS (Requires additional steps)
  • Android

Requirements

Using TensorFlowSharp with ML-Agents

Go to Edit -> Player Settings and add ENABLE_TENSORFLOW to the Scripting Define Symbols for each type of device you want to use (PC, Mac and Linux Standalone, iOS or Android).

Set the Brain you used for training to Learning. Drag your_name_graph.bytes into Unity and then drag it into The Model field in the Brain.

iOS additional instructions for building

  • Before build your game against iOS platform, make sure you've set the flag ENABLE_TENSORFLOW for it.
  • Once you build the project for iOS in the editor, open the .xcodeproj file within the project folder using Xcode.
  • Set up your ios account following the iOS Account setup page.
  • In Build Settings > Linking > Other Linker Flags:
    • Double click on the flag list to expand the list
    • Add -force_load
    • Drag the library libtensorflow-core.a from the Project Navigator on the left under Libraries/ML-Agents/Plugins/iOS into the flag list, after -force_load.