浏览代码

Remove obsolete Observation class and ToProto()

/MLA-1734-demo-provider
Ruo-Ping Dong 4 年前
当前提交
38e56032
共有 2 个文件被更改,包括 0 次插入64 次删除
  1. 36
      com.unity.ml-agents/Runtime/Communicator/GrpcExtensions.cs
  2. 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>

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;
}
}
正在加载...
取消
保存