浏览代码

fix NPE in model validation code, better error message

/release_2_verified
Chris Elion 4 年前
当前提交
e2d1263f
共有 3 个文件被更改,包括 25 次插入13 次删除
  1. 12
      com.unity.ml-agents/Runtime/Communicator/RpcCommunicator.cs
  2. 11
      com.unity.ml-agents/Runtime/Constants.cs
  3. 15
      com.unity.ml-agents/Runtime/Inference/BarracudaModelParamLoader.cs

12
com.unity.ml-agents/Runtime/Communicator/RpcCommunicator.cs


/// Responsible for communication with External using gRPC.
internal class RpcCommunicator : ICommunicator
{
// The python package version must be >= s_MinSupportedPythonPackageVersion
// and <= s_MaxSupportedPythonPackageVersion.
static Version s_MinSupportedPythonPackageVersion = new Version("0.16.1");
static Version s_MaxSupportedPythonPackageVersion = new Version("0.20.0");
public event QuitCommandHandler QuitCommandReceived;
public event ResetCommandHandler ResetCommandReceived;

return false;
}
if (pythonVersion < s_MinSupportedPythonPackageVersion ||
pythonVersion > s_MaxSupportedPythonPackageVersion)
if (pythonVersion < PythonTrainerVersions.s_MinSupportedVersion ||
pythonVersion > PythonTrainerVersions.s_MaxSupportedVersion)
{
return false;
}

"It is strongly recommended that you use a Python package between {1} and {2}. " +
"Training will proceed, but the output format may be different.",
pythonPackageVersion,
s_MinSupportedPythonPackageVersion,
s_MaxSupportedPythonPackageVersion
PythonTrainerVersions.s_MinSupportedVersion,
PythonTrainerVersions.s_MaxSupportedVersion
);
}
}

11
com.unity.ml-agents/Runtime/Constants.cs


using System;
namespace Unity.MLAgents
{
/// <summary>

Default = 0,
Sensors = 50
}
internal static class PythonTrainerVersions
{
// The python package version must be >= s_MinSupportedPythonPackageVersion
// and <= s_MaxSupportedPythonPackageVersion.
internal static Version s_MinSupportedVersion = new Version("0.16.1");
internal static Version s_MaxSupportedVersion = new Version("0.20.0");
}
}

15
com.unity.ml-agents/Runtime/Inference/BarracudaModelParamLoader.cs


}
var modelApiVersion = (int)model.GetTensorByName(TensorNames.VersionNumber)[0];
var memorySize = (int)model.GetTensorByName(TensorNames.MemorySize)[0];
var isContinuousInt = (int)model.GetTensorByName(TensorNames.IsContinuousControl)[0];
var isContinuous = GetActionType(isContinuousInt);
var actionSize = (int)model.GetTensorByName(TensorNames.ActionOutputShape)[0];
if (modelApiVersion == -1)
{
failedModelChecks.Add(

if (modelApiVersion > k_ApiVersion)
{
var minTrainerVersion = PythonTrainerVersions.s_MinSupportedVersion;
var maxTrainerVersion = PythonTrainerVersions.s_MaxSupportedVersion;
"Either retrain with an older trainer, or update to a newer version of com.unity.ml-agents.\n" +
$"Either retrain with an older trainer (between versions {minTrainerVersion} and {maxTrainerVersion}), " +
$"or update to a newer version of com.unity.ml-agents.\n" +
var memorySize = (int)model.GetTensorByName(TensorNames.MemorySize)[0];
var isContinuousInt = (int)model.GetTensorByName(TensorNames.IsContinuousControl)[0];
var isContinuous = GetActionType(isContinuousInt);
var actionSize = (int)model.GetTensorByName(TensorNames.ActionOutputShape)[0];
failedModelChecks.AddRange(
CheckIntScalarPresenceHelper(new Dictionary<string, int>()

正在加载...
取消
保存