Andrew Cohen
5 年前
当前提交
b4f52c88
共有 51 个文件被更改,包括 2887 次插入 和 5855 次删除
-
2.yamato/gym-interface-test.yml
-
4.yamato/protobuf-generation-test.yml
-
2.yamato/python-ll-api-test.yml
-
5.yamato/standalone-build-test.yml
-
11.yamato/training-int-tests.yml
-
2README.md
-
4com.unity.ml-agents/CHANGELOG.md
-
24com.unity.ml-agents/Runtime/Academy.cs
-
6com.unity.ml-agents/Runtime/Agent.cs
-
34com.unity.ml-agents/Runtime/DecisionRequester.cs
-
44com.unity.ml-agents/Runtime/SideChannels/IncomingMessage.cs
-
69com.unity.ml-agents/Runtime/Timer.cs
-
47com.unity.ml-agents/Tests/Editor/MLAgentsEditModeTest.cs
-
102com.unity.ml-agents/Tests/Editor/PublicAPI/PublicApiValidation.cs
-
26com.unity.ml-agents/Tests/Editor/SideChannelTests.cs
-
2com.unity.ml-agents/Tests/Editor/TimerTest.cs
-
16com.unity.ml-agents/package.json
-
3docs/Getting-Started.md
-
10docs/ML-Agents-Overview.md
-
1docs/Migrating.md
-
2docs/Training-ML-Agents.md
-
999docs/images/3dball_big.png
-
852docs/images/3dball_small.png
-
974docs/images/curriculum.png
-
999docs/images/ml-agents-LSTM.png
-
181docs/images/monitor.png
-
2ml-agents-envs/mlagents_envs/environment.py
-
38ml-agents-envs/mlagents_envs/side_channel/incoming_message.py
-
20ml-agents-envs/mlagents_envs/tests/test_side_channel.py
-
7ml-agents-envs/mlagents_envs/tests/test_timers.py
-
39ml-agents-envs/mlagents_envs/timers.py
-
1ml-agents/mlagents/trainers/agent_processor.py
-
14ml-agents/mlagents/trainers/demo_loader.py
-
1ml-agents/mlagents/trainers/env_manager.py
-
12ml-agents/mlagents/trainers/learn.py
-
24ml-agents/mlagents/trainers/tests/test_demo_loader.py
-
2ml-agents/tests/yamato/scripts/run_llapi.py
-
2ml-agents/tests/yamato/standalone_build_tests.py
-
13ml-agents/tests/yamato/training_int_tests.py
-
37ml-agents/tests/yamato/yamato_utils.py
-
1utils/make_readme_table.py
-
129com.unity.ml-agents/Tests/Runtime/RuntimeAPITest.cs
-
11com.unity.ml-agents/Tests/Runtime/RuntimeAPITest.cs.meta
-
25com.unity.ml-agents/Tests/Runtime/Unity.ML-Agents.Runtime.Tests.asmdef
-
7com.unity.ml-agents/Tests/Runtime/Unity.ML-Agents.Runtime.Tests.asmdef.meta
-
429com.unity.ml-agents/Tests/Runtime/SerializeTestScene.unity
-
7com.unity.ml-agents/Tests/Runtime/SerializeTestScene.unity.meta
-
1001docs/images/banana.png
-
1001docs/images/running-a-pretrained-model.gif
-
497docs/images/3dballhard.png
-
1001docs/images/bananaimitation.png
|
|||
{ |
|||
"name": "com.unity.ml-agents", |
|||
"displayName":"ML Agents", |
|||
"version": "0.15.0-preview", |
|||
"unity": "2018.4", |
|||
"description": "Add interactivity to your game with Machine Learning Agents trained using Deep Reinforcement Learning.", |
|||
"dependencies": { |
|||
"com.unity.barracuda": "0.6.1-preview" |
|||
} |
|||
"name": "com.unity.ml-agents", |
|||
"displayName": "ML Agents", |
|||
"version": "0.15.1-preview", |
|||
"unity": "2018.4", |
|||
"description": "Add interactivity to your game with Machine Learning Agents trained using Deep Reinforcement Learning.", |
|||
"dependencies": { |
|||
"com.unity.barracuda": "0.6.1-preview" |
|||
} |
|||
} |
999
docs/images/3dball_big.png
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
999
docs/images/ml-agents-LSTM.png
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
|
|||
#if UNITY_INCLUDE_TESTS
|
|||
using System.Collections; |
|||
using System.Collections.Generic; |
|||
using MLAgents; |
|||
using MLAgents.Policies; |
|||
using MLAgents.Sensors; |
|||
using NUnit.Framework; |
|||
using UnityEngine; |
|||
using UnityEngine.TestTools; |
|||
|
|||
namespace Tests |
|||
{ |
|||
|
|||
public class PublicApiAgent : Agent |
|||
{ |
|||
public int numHeuristicCalls; |
|||
|
|||
public override float[] Heuristic() |
|||
{ |
|||
numHeuristicCalls++; |
|||
return base.Heuristic(); |
|||
} |
|||
}// Simple SensorComponent that sets up a StackingSensor
|
|||
public class StackingComponent : SensorComponent |
|||
{ |
|||
public SensorComponent wrappedComponent; |
|||
public int numStacks; |
|||
|
|||
public override ISensor CreateSensor() |
|||
{ |
|||
var wrappedSensor = wrappedComponent.CreateSensor(); |
|||
return new StackingSensor(wrappedSensor, numStacks); |
|||
} |
|||
|
|||
public override int[] GetObservationShape() |
|||
{ |
|||
int[] shape = (int[]) wrappedComponent.GetObservationShape().Clone(); |
|||
for (var i = 0; i < shape.Length; i++) |
|||
{ |
|||
shape[i] *= numStacks; |
|||
} |
|||
|
|||
return shape; |
|||
} |
|||
} |
|||
|
|||
public class RuntimeApiTest |
|||
{ |
|||
[SetUp] |
|||
public static void Setup() |
|||
{ |
|||
Academy.Instance.AutomaticSteppingEnabled = false; |
|||
} |
|||
|
|||
[UnityTest] |
|||
public IEnumerator RuntimeApiTestWithEnumeratorPasses() |
|||
{ |
|||
var gameObject = new GameObject(); |
|||
|
|||
var behaviorParams = gameObject.AddComponent<BehaviorParameters>(); |
|||
behaviorParams.brainParameters.vectorObservationSize = 3; |
|||
behaviorParams.brainParameters.numStackedVectorObservations = 2; |
|||
behaviorParams.brainParameters.vectorActionDescriptions = new[] { "TestActionA", "TestActionB" }; |
|||
behaviorParams.brainParameters.vectorActionSize = new[] { 2, 2 }; |
|||
behaviorParams.brainParameters.vectorActionSpaceType = SpaceType.Discrete; |
|||
behaviorParams.behaviorName = "TestBehavior"; |
|||
behaviorParams.TeamId = 42; |
|||
behaviorParams.useChildSensors = true; |
|||
|
|||
|
|||
// Can't actually create an Agent with InferenceOnly and no model, so change back
|
|||
behaviorParams.behaviorType = BehaviorType.Default; |
|||
|
|||
var sensorComponent = gameObject.AddComponent<RayPerceptionSensorComponent3D>(); |
|||
sensorComponent.sensorName = "ray3d"; |
|||
sensorComponent.detectableTags = new List<string> { "Player", "Respawn" }; |
|||
sensorComponent.raysPerDirection = 3; |
|||
|
|||
// Make a StackingSensor that wraps the RayPerceptionSensorComponent3D
|
|||
// This isn't necessarily practical, just to ensure that it can be done
|
|||
var wrappingSensorComponent = gameObject.AddComponent<StackingComponent>(); |
|||
wrappingSensorComponent.wrappedComponent = sensorComponent; |
|||
wrappingSensorComponent.numStacks = 3; |
|||
|
|||
// ISensor isn't set up yet.
|
|||
Assert.IsNull(sensorComponent.raySensor); |
|||
|
|||
|
|||
// Make sure we can set the behavior type correctly after the agent is initialized
|
|||
// (this creates a new policy).
|
|||
behaviorParams.behaviorType = BehaviorType.HeuristicOnly; |
|||
|
|||
// Agent needs to be added after everything else is setup.
|
|||
var agent = gameObject.AddComponent<PublicApiAgent>(); |
|||
|
|||
// DecisionRequester has to be added after Agent.
|
|||
var decisionRequester = gameObject.AddComponent<DecisionRequester>(); |
|||
decisionRequester.DecisionPeriod = 2; |
|||
decisionRequester.TakeActionsBetweenDecisions = true; |
|||
|
|||
|
|||
// Initialization should set up the sensors
|
|||
Assert.IsNotNull(sensorComponent.raySensor); |
|||
|
|||
// Let's change the inference device
|
|||
var otherDevice = behaviorParams.inferenceDevice == InferenceDevice.CPU ? InferenceDevice.GPU : InferenceDevice.CPU; |
|||
agent.SetModel(behaviorParams.behaviorName, behaviorParams.model, otherDevice); |
|||
|
|||
agent.AddReward(1.0f); |
|||
|
|||
// skip a frame.
|
|||
yield return null; |
|||
|
|||
Ac |