浏览代码

Remove obsolete Observation class and ToProto() function (#4499)

Remove obsolete Observation class and ToProto() function
/MLA-1734-demo-provider
GitHub 4 年前
当前提交
b57f1294
共有 3 个文件被更改,包括 0 次插入75 次删除
  1. 36
      com.unity.ml-agents/Runtime/Communicator/GrpcExtensions.cs
  2. 11
      com.unity.ml-agents/Runtime/Sensors/Observation.cs.meta
  3. 28
      com.unity.ml-agents/Runtime/Sensors/Observation.cs

36
com.unity.ml-agents/Runtime/Communicator/GrpcExtensions.cs


#endregion
#region Observations
public static ObservationProto ToProto(this Observation obs)
{
ObservationProto obsProto = null;
if (obs.CompressedData != null)
{
// Make sure that uncompressed data is empty
if (obs.FloatData.Count != 0)
{
Debug.LogWarning("Observation has both compressed and uncompressed data set. Using compressed.");
}
obsProto = new ObservationProto
{
CompressedData = ByteString.CopyFrom(obs.CompressedData),
CompressionType = (CompressionTypeProto)obs.CompressionType,
};
}
else
{
var floatDataProto = new ObservationProto.Types.FloatData
{
Data = { obs.FloatData },
};
obsProto = new ObservationProto
{
FloatData = floatDataProto,
CompressionType = (CompressionTypeProto)obs.CompressionType,
};
}
obsProto.Shape.AddRange(obs.Shape);
return obsProto;
}
/// <summary>
/// Static flag to make sure that we only fire the warning once.
/// </summary>

11
com.unity.ml-agents/Runtime/Sensors/Observation.cs.meta


fileFormatVersion: 2
guid: e9292f3e3b1864e0fbe1e9bb9a29d4ed
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

28
com.unity.ml-agents/Runtime/Sensors/Observation.cs


using System;
namespace Unity.MLAgents.Sensors
{
internal struct Observation
{
/// <summary>
/// The compressed sensor data. Assumed to be non-null if CompressionType != CompressionType.None
/// </summary>
public byte[] CompressedData;
/// <summary>
/// Uncompressed sensor data. Assumed to be non-empty if CompressionType == CompressionType.None
/// </summary>
public ArraySegment<float> FloatData;
/// <summary>
/// The format of the compressed data
/// </summary>
public SensorCompressionType CompressionType;
/// <summary>
/// The uncompressed dimensions of the data.
/// E.g. for RGB visual observations, this will be {Height, Width, 3}
/// </summary>
public int[] Shape;
}
}
正在加载...
取消
保存