democratizing deep learning with unity ml-agents · 2018. 4. 23. · embed agents (unity) •once a...

44
Democratizing Deep Learning with Unity ML-Agents Arthur Juliani

Upload: others

Post on 30-Jun-2021

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Democratizing Deep Learning with Unity ML-Agents · 2018. 4. 23. · Embed Agents (Unity) •Once a model is trained, it can be exported into the Unity project. •Simply drop .bytes

Democratizing Deep Learning with Unity

ML-Agents

Arthur Juliani

Page 2: Democratizing Deep Learning with Unity ML-Agents · 2018. 4. 23. · Embed Agents (Unity) •Once a model is trained, it can be exported into the Unity project. •Simply drop .bytes

About Unity

“Creation Engine”

• Games

• AR/VR

• Cinematics

• Simulations

• 40+ Platforms

• Free for personal use

Page 3: Democratizing Deep Learning with Unity ML-Agents · 2018. 4. 23. · Embed Agents (Unity) •Once a model is trained, it can be exported into the Unity project. •Simply drop .bytes

Machine Learning

Page 4: Democratizing Deep Learning with Unity ML-Agents · 2018. 4. 23. · Embed Agents (Unity) •Once a model is trained, it can be exported into the Unity project. •Simply drop .bytes

Machine Learning And Games?

Page 5: Democratizing Deep Learning with Unity ML-Agents · 2018. 4. 23. · Embed Agents (Unity) •Once a model is trained, it can be exported into the Unity project. •Simply drop .bytes
Page 6: Democratizing Deep Learning with Unity ML-Agents · 2018. 4. 23. · Embed Agents (Unity) •Once a model is trained, it can be exported into the Unity project. •Simply drop .bytes
Page 7: Democratizing Deep Learning with Unity ML-Agents · 2018. 4. 23. · Embed Agents (Unity) •Once a model is trained, it can be exported into the Unity project. •Simply drop .bytes
Page 8: Democratizing Deep Learning with Unity ML-Agents · 2018. 4. 23. · Embed Agents (Unity) •Once a model is trained, it can be exported into the Unity project. •Simply drop .bytes

Yet another ML training platform?

Page 9: Democratizing Deep Learning with Unity ML-Agents · 2018. 4. 23. · Embed Agents (Unity) •Once a model is trained, it can be exported into the Unity project. •Simply drop .bytes

ML Training Platforms

VizDoom Malmo Atari

PyBulletDeepMind Lab SCII LE

Page 10: Democratizing Deep Learning with Unity ML-Agents · 2018. 4. 23. · Embed Agents (Unity) •Once a model is trained, it can be exported into the Unity project. •Simply drop .bytes

Visual Complexity Cognitive ComplexityPhysical Complexity

ML Training Environments

Page 11: Democratizing Deep Learning with Unity ML-Agents · 2018. 4. 23. · Embed Agents (Unity) •Once a model is trained, it can be exported into the Unity project. •Simply drop .bytes

The Unity

Ecosystem

Page 12: Democratizing Deep Learning with Unity ML-Agents · 2018. 4. 23. · Embed Agents (Unity) •Once a model is trained, it can be exported into the Unity project. •Simply drop .bytes

How does it work?

Page 13: Democratizing Deep Learning with Unity ML-Agents · 2018. 4. 23. · Embed Agents (Unity) •Once a model is trained, it can be exported into the Unity project. •Simply drop .bytes

Unity ML-Agents Workflow

Create Environment Train Agents Embed Agents

Page 14: Democratizing Deep Learning with Unity ML-Agents · 2018. 4. 23. · Embed Agents (Unity) •Once a model is trained, it can be exported into the Unity project. •Simply drop .bytes

Unity ML-Agents Workflow

Create Environment Train Agents Embed Agents

Page 15: Democratizing Deep Learning with Unity ML-Agents · 2018. 4. 23. · Embed Agents (Unity) •Once a model is trained, it can be exported into the Unity project. •Simply drop .bytes

Create Environment (Unity)

1. Create Scene

2. Add Academy, Brain(s), and

Agent(s)

3. Define Observations,

Actions, and Rewards

4. Build Executable

Page 16: Democratizing Deep Learning with Unity ML-Agents · 2018. 4. 23. · Embed Agents (Unity) •Once a model is trained, it can be exported into the Unity project. •Simply drop .bytes

Create Environment (Unity)

Observation & Act

Decide

Coordinate

Page 17: Democratizing Deep Learning with Unity ML-Agents · 2018. 4. 23. · Embed Agents (Unity) •Once a model is trained, it can be exported into the Unity project. •Simply drop .bytes

Agents

• Agents are GameObjects within the Unity scene.

• They perceive the environment via observations, take

actions, and optionally receive rewards.

• Each agent is linked to a brain, which makes decisions for

the agent.

Page 18: Democratizing Deep Learning with Unity ML-Agents · 2018. 4. 23. · Embed Agents (Unity) •Once a model is trained, it can be exported into the Unity project. •Simply drop .bytes

Brains

• Player – Actions are decided by user input through

keyboard or gamepad.

• Heuristic – Actions are decided by C# script using state

input.

• External – Actions are decided using Tensorflow via

Python interface.

• Internal – Actions are decided using Tensorflow model

embedded into project.

Page 19: Democratizing Deep Learning with Unity ML-Agents · 2018. 4. 23. · Embed Agents (Unity) •Once a model is trained, it can be exported into the Unity project. •Simply drop .bytes

Unity ML-Agents Workflow

Build Environment Train Agents Embed Agents

Page 20: Democratizing Deep Learning with Unity ML-Agents · 2018. 4. 23. · Embed Agents (Unity) •Once a model is trained, it can be exported into the Unity project. •Simply drop .bytes

Training Methods

Reinforcement Learning

● Learn through rewards

● Trial-and-error

● Super-speed simulation

● Agent becomes “optimal” at task

Imitation Learning

● Learn through demonstrations

● No rewards necessary

● Real-time interaction

● Agent becomes “human-like” at task

Page 21: Democratizing Deep Learning with Unity ML-Agents · 2018. 4. 23. · Embed Agents (Unity) •Once a model is trained, it can be exported into the Unity project. •Simply drop .bytes

Agent Training Process

Page 22: Democratizing Deep Learning with Unity ML-Agents · 2018. 4. 23. · Embed Agents (Unity) •Once a model is trained, it can be exported into the Unity project. •Simply drop .bytes

Train Agents (Python)

• Launch an environment from python withenv = UnityEnvironment(“my_environment”)

• Interact with gym-like interface:

env.reset()

env.step()

env.close()

Page 23: Democratizing Deep Learning with Unity ML-Agents · 2018. 4. 23. · Embed Agents (Unity) •Once a model is trained, it can be exported into the Unity project. •Simply drop .bytes

Train Agents (Python)

• PPO and Behavioral Cloning algorithms

included by default.

• Works with Continuous and Discrete

Control, plus image and/or vector inputs.

• Monitor progress with TensorBoard.

Page 24: Democratizing Deep Learning with Unity ML-Agents · 2018. 4. 23. · Embed Agents (Unity) •Once a model is trained, it can be exported into the Unity project. •Simply drop .bytes

Unity ML-Agents Workflow

Build Environment Train Agents Embed Agents

Page 25: Democratizing Deep Learning with Unity ML-Agents · 2018. 4. 23. · Embed Agents (Unity) •Once a model is trained, it can be exported into the Unity project. •Simply drop .bytes

Embed Agents (Unity)

• Once a model is trained, it can be

exported into the Unity project.

• Simply drop .bytes file into Unity

project, and use it in corresponding

Brain with “Internal” mode.

• Support for Mac, Windows, Linux,

iOS, and Android.

Page 26: Democratizing Deep Learning with Unity ML-Agents · 2018. 4. 23. · Embed Agents (Unity) •Once a model is trained, it can be exported into the Unity project. •Simply drop .bytes

Learning Scenarios

Page 27: Democratizing Deep Learning with Unity ML-Agents · 2018. 4. 23. · Embed Agents (Unity) •Once a model is trained, it can be exported into the Unity project. •Simply drop .bytes

Twelve Agents, One Brain,

Independent Rewards

Page 28: Democratizing Deep Learning with Unity ML-Agents · 2018. 4. 23. · Embed Agents (Unity) •Once a model is trained, it can be exported into the Unity project. •Simply drop .bytes
Page 29: Democratizing Deep Learning with Unity ML-Agents · 2018. 4. 23. · Embed Agents (Unity) •Once a model is trained, it can be exported into the Unity project. •Simply drop .bytes

Two Agents, One Brain,

Cooperative Rewards

Page 30: Democratizing Deep Learning with Unity ML-Agents · 2018. 4. 23. · Embed Agents (Unity) •Once a model is trained, it can be exported into the Unity project. •Simply drop .bytes
Page 31: Democratizing Deep Learning with Unity ML-Agents · 2018. 4. 23. · Embed Agents (Unity) •Once a model is trained, it can be exported into the Unity project. •Simply drop .bytes

Four Agents, Two Brains:

Competitive Multi-Agent

Page 32: Democratizing Deep Learning with Unity ML-Agents · 2018. 4. 23. · Embed Agents (Unity) •Once a model is trained, it can be exported into the Unity project. •Simply drop .bytes

Multi-Stage Soccer Training

Defense

Train one brain with

negative reward for

ball entering their goal

Offense

Train one brain with

positive reward for ball

entering opponents goal

Combined

Train both brains

together to play against

opponent team

Page 33: Democratizing Deep Learning with Unity ML-Agents · 2018. 4. 23. · Embed Agents (Unity) •Once a model is trained, it can be exported into the Unity project. •Simply drop .bytes
Page 34: Democratizing Deep Learning with Unity ML-Agents · 2018. 4. 23. · Embed Agents (Unity) •Once a model is trained, it can be exported into the Unity project. •Simply drop .bytes

Physical Manipulation

Reacher Crawler

Page 35: Democratizing Deep Learning with Unity ML-Agents · 2018. 4. 23. · Embed Agents (Unity) •Once a model is trained, it can be exported into the Unity project. •Simply drop .bytes

Additional Features

Page 36: Democratizing Deep Learning with Unity ML-Agents · 2018. 4. 23. · Embed Agents (Unity) •Once a model is trained, it can be exported into the Unity project. •Simply drop .bytes

Curriculum Learning

Page 37: Democratizing Deep Learning with Unity ML-Agents · 2018. 4. 23. · Embed Agents (Unity) •Once a model is trained, it can be exported into the Unity project. •Simply drop .bytes

Curriculum Learning

• Bootstrap learning of difficult

task with simpler task

• Utilize custom reset

parameters

• Change environment task

based on reward or fixed

progress

Easy

Difficult

Page 38: Democratizing Deep Learning with Unity ML-Agents · 2018. 4. 23. · Embed Agents (Unity) •Once a model is trained, it can be exported into the Unity project. •Simply drop .bytes
Page 39: Democratizing Deep Learning with Unity ML-Agents · 2018. 4. 23. · Embed Agents (Unity) •Once a model is trained, it can be exported into the Unity project. •Simply drop .bytes
Page 40: Democratizing Deep Learning with Unity ML-Agents · 2018. 4. 23. · Embed Agents (Unity) •Once a model is trained, it can be exported into the Unity project. •Simply drop .bytes

Memory-enhanced agents

Page 41: Democratizing Deep Learning with Unity ML-Agents · 2018. 4. 23. · Embed Agents (Unity) •Once a model is trained, it can be exported into the Unity project. •Simply drop .bytes
Page 42: Democratizing Deep Learning with Unity ML-Agents · 2018. 4. 23. · Embed Agents (Unity) •Once a model is trained, it can be exported into the Unity project. •Simply drop .bytes
Page 43: Democratizing Deep Learning with Unity ML-Agents · 2018. 4. 23. · Embed Agents (Unity) •Once a model is trained, it can be exported into the Unity project. •Simply drop .bytes

Try it Now

https://github.com/Unity-Technologies/ml-agents

Page 44: Democratizing Deep Learning with Unity ML-Agents · 2018. 4. 23. · Embed Agents (Unity) •Once a model is trained, it can be exported into the Unity project. •Simply drop .bytes

Thank You!

Questions?@awjuliani

[email protected]