Class DtypeObservation<TObs, TAct>
Converts every observation to a dtype, as Gymnasium's DtypeObservation does: a Box,
MultiDiscrete or MultiBinary observation keeps its shape, a Discrete one becomes a 0-d array
of the dtype (a NumPy scalar), and the space follows.
public class DtypeObservation<TObs, TAct> : TransformObservation<NDArray, TObs, TAct>, IDynamicAttributes, IWrapper, IEnv, IDisposable, IRecordConstructorArgs
Type Parameters
TObsThe env's observation type: arrays or numbers (NDArray, or object).
TActThe action type, passed through.
- Inheritance
-
ObservationWrapper<NDArray, TObs, TAct>TransformObservation<NDArray, TObs, TAct>DtypeObservation<TObs, TAct>
- Implements
- Inherited Members
- Extension Methods
Remarks
The conversion is NumPy's dtype.type(obs), an unsafe cast: float to integer truncates, and out-of-range
values wrap. A Discrete(n, start) space becomes Box(start, start + n - 1, (), dtype), a
MultiBinary one Box(0, 1, shape, dtype), a MultiDiscrete one keeps its nvec and
start.
Reference: gymnasium/wrappers/transform_observation.py.
Constructors
DtypeObservation(Env<TObs, TAct>, DtypeObservationOptions)
Builds the instance from its options record: the properties set, the constructor's defaults for the rest.
public DtypeObservation(Env<TObs, TAct> env, DtypeObservationOptions options)
Parameters
envEnv<TObs, TAct>The env to wrap.
optionsDtypeObservationOptionsThe options.
Exceptions
- ArgumentNullException
Thrown when
optionsis null.- TypeError
Thrown when a required argument is unset, with Python's missing-argument message.
DtypeObservation(Env<TObs, TAct>, object)
Wraps env.
public DtypeObservation(Env<TObs, TAct> env, object dtype)
Parameters
envEnv<TObs, TAct>The env; its observation space must be a
Box,Discrete,MultiDiscreteorMultiBinary.dtypeobjectThe dtype: a DType (
np.float32), its name ("float32"), an NPTypeCode or a .NET Type.
Exceptions
- TypeError
Thrown when the space is of another kind (Gymnasium's message), the dtype cannot be read, or
envis null.
Properties
Dtype
The dtype as given (dtype).
public object Dtype { get; }