|
|
|
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Linq; |
|
|
|
using Barracuda; |
|
|
|
using Unity.Barracuda; |
|
|
|
using MLAgents.Sensors; |
|
|
|
using MLAgents.Policies; |
|
|
|
|
|
|
|
|
|
|
"suggest Continuous Control."); |
|
|
|
return failedModelChecks; |
|
|
|
} |
|
|
|
var tensorTester = new Dictionary<string, Func<BrainParameters, TensorShape, int, string>>(); |
|
|
|
var tensorTester = new Dictionary<string, Func<BrainParameters, TensorShape?, int, string>>(); |
|
|
|
if (brainParameters.VectorActionSpaceType == SpaceType.Continuous) |
|
|
|
{ |
|
|
|
tensorTester[TensorNames.ActionOutput] = CheckContinuousActionOutputShape; |
|
|
|
|
|
|
{ |
|
|
|
if (tensorTester.ContainsKey(name)) |
|
|
|
{ |
|
|
|
var tester = tensorTester[name]; |
|
|
|
Func<BrainParameters, TensorShape?, int, string> tester = tensorTester[name]; |
|
|
|
var error = tester.Invoke(brainParameters, model.GetShapeByName(name), modelActionSize); |
|
|
|
if (error != null) |
|
|
|
{ |
|
|
|
|
|
|
/// check failed. If the check passed, returns null.
|
|
|
|
/// </returns>
|
|
|
|
static string CheckDiscreteActionOutputShape( |
|
|
|
BrainParameters brainParameters, TensorShape shape, int modelActionSize) |
|
|
|
BrainParameters brainParameters, TensorShape? shape, int modelActionSize) |
|
|
|
{ |
|
|
|
var bpActionSize = brainParameters.VectorActionSize.Sum(); |
|
|
|
if (modelActionSize != bpActionSize) |
|
|
|
|
|
|
/// <returns>If the Check failed, returns a string containing information about why the
|
|
|
|
/// check failed. If the check passed, returns null.</returns>
|
|
|
|
static string CheckContinuousActionOutputShape( |
|
|
|
BrainParameters brainParameters, TensorShape shape, int modelActionSize) |
|
|
|
BrainParameters brainParameters, TensorShape? shape, int modelActionSize) |
|
|
|
{ |
|
|
|
var bpActionSize = brainParameters.VectorActionSize[0]; |
|
|
|
if (modelActionSize != bpActionSize) |
|
|
|