浏览代码

Make ObsSpec.Shape and DimProps internal, add get props

/v2-staging-rebase
Chris Elion 4 年前
当前提交
d8d88ac7
共有 2 个文件被更改,包括 21 次插入7 次删除
  1. 20
      com.unity.ml-agents/Runtime/Sensors/ObservationSpec.cs
  2. 8
      com.unity.ml-agents/Runtime/Sensors/StackingSensor.cs

20
com.unity.ml-agents/Runtime/Sensors/ObservationSpec.cs


/// </summary>
public struct ObservationSpec
{
internal InplaceArray<int> m_Shape;
public InplaceArray<int> Shape;
public InplaceArray<int> Shape
{
get => m_Shape;
}
internal InplaceArray<DimensionProperty> m_DimensionProperties;
/// <summary>
/// The properties of each dimensions of the observation.

/// It is generally recommended to not modify this from the default values,
/// It is generally recommended to use default values provided by helper functions,
public InplaceArray<DimensionProperty> DimensionProperties;
public InplaceArray<DimensionProperty> DimensionProperties
{
get => m_DimensionProperties;
}
/// <summary>
/// The type of the observation, e.g. whether they are generic or

{
throw new UnityAgentsException("shape and dimensionProperties must have the same length.");
}
Shape = shape;
DimensionProperties = dimensionProperties;
m_Shape = shape;
m_DimensionProperties = dimensionProperties;
ObservationType = observationType;
}
}

8
com.unity.ml-agents/Runtime/Sensors/StackingSensor.cs


m_Name = $"StackingSensor_size{numStackedObservations}_{wrapped.GetName()}";
m_WrappedSpec = wrapped.GetObservationSpec();
m_ObservationSpec = m_WrappedSpec;
// Set up the cached observation spec for the StackingSensor
var newShape = m_WrappedSpec.Shape;
m_ObservationSpec.Shape[m_ObservationSpec.NumDimensions - 1] *= numStackedObservations;
newShape[newShape.Length - 1] *= numStackedObservations;
m_ObservationSpec = new ObservationSpec(
newShape, m_WrappedSpec.DimensionProperties, m_WrappedSpec.ObservationType
);
// Initialize uncompressed buffer anyway in case python trainer does not
// support the compression mapping and has to fall back to uncompressed obs.

正在加载...
取消
保存