浏览代码

addressing preliminary comments

/layernorm
vincentpierre 4 年前
当前提交
90f6dbe2
共有 5 个文件被更改,包括 31 次插入9 次删除
  1. 3
      com.unity.ml-agents/Runtime/Communicator/GrpcExtensions.cs
  2. 13
      com.unity.ml-agents/Runtime/Sensors/BufferSensor.cs
  3. 16
      com.unity.ml-agents/Runtime/Sensors/BufferSensorComponent.cs
  4. 6
      com.unity.ml-agents/Runtime/Sensors/IDimensionPropertiesSensor.cs
  5. 2
      ml-agents-envs/mlagents_envs/base_env.py

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


int[] intDimensionProperties = new int[dimensionProperties.Length];
for (int i = 0; i < dimensionProperties.Length; i++)
{
intDimensionProperties[i] = (int)dimensionProperties[i];
observationProto.DimensionProperties.Add((int)dimensionProperties[i]);
observationProto.DimensionProperties.AddRange(intDimensionProperties);
}
}

13
com.unity.ml-agents/Runtime/Sensors/BufferSensor.cs


namespace Unity.MLAgents.Sensors
{
public class BufferSensor : ISensor
public class BufferSensor : ISensor, IDimensionPropertiesSensor
{
private int m_MaxNumObs;
private int m_ObsSize;

return new int[] { m_MaxNumObs, m_ObsSize };
}
/// <inheritdoc/>
public DimensionProperty[] GetDimensionProperties()
{
return new DimensionProperty[]{
DimensionProperty.VariableSize,
DimensionProperty.None
};
}
/// <summary>
/// Appends an observation to the buffer. If the buffer is full (maximum number
/// of observation is reached) the observation will be ignored. the length of

}
for (int i = 0; i < obs.Length; i++)
{
m_ObservationBuffer[m_CurrentNumObservables * m_MaxNumObs + i] = obs[i];
m_ObservationBuffer[m_CurrentNumObservables * m_ObsSize + i] = obs[i];
}
m_CurrentNumObservables++;
}

16
com.unity.ml-agents/Runtime/Sensors/BufferSensorComponent.cs


{
public int ObservableSize;
public int MaxNumObservables;
private BufferSensor m_Sensor;
return new BufferSensor(ObservableSize, MaxNumObservables);
m_Sensor = new BufferSensor(ObservableSize, MaxNumObservables);
return m_Sensor;
}
/// <inheritdoc/>

}
/// <summary>
/// Appends an observation to the buffer. If the buffer is full (maximum number
/// of observation is reached) the observation will be ignored. the length of
/// the provided observation array must be equal to the observation size of
/// the buffer sensor.
/// </summary>
/// <param name="obs"> The float array observation</param>
public void AppendObservation(float[] obs)
{
m_Sensor.AppendObservation(obs);
}
}
}

6
com.unity.ml-agents/Runtime/Sensors/IDimensionPropertiesSensor.cs


/// The Dimension property flags of the observations
/// </summary>
[System.Flags]
internal enum DimensionProperty
public enum DimensionProperty
{
/// <summary>
/// No properties specified.

/// Means that there can be a variable number of observations in this dimension.
/// The observations are unordered.
/// </summary>
VariableSize = 3,
VariableSize = 4,
}

internal interface IDimensionPropertiesSensor : ISensor
public interface IDimensionPropertiesSensor : ISensor
{
/// <summary>
/// Returns the array containing the properties of each dimensions of the

2
ml-agents-envs/mlagents_envs/base_env.py


Means that there can be a variable number of observations in this dimension.
The observations are unordered.
"""
VARIABLE_SIZE = 3
VARIABLE_SIZE = 4
class ObservationSpec(NamedTuple):

正在加载...
取消
保存