Class ReshapeObservation<TObs, TAct>
Reshapes every array observation, as Gymnasium's ReshapeObservation does; the space's bounds are reshaped with it.
public class ReshapeObservation<TObs, TAct> : TransformObservation<NDArray, TObs, TAct>, IDynamicAttributes, IWrapper, IEnv, IDisposable, IRecordConstructorArgs
Type Parameters
TObsThe env's observation type: arrays (NDArray, or object holding them).
TActThe action type, passed through.
- Inheritance
-
ObservationWrapper<NDArray, TObs, TAct>TransformObservation<NDArray, TObs, TAct>ReshapeObservation<TObs, TAct>
- Implements
- Inherited Members
- Extension Methods
Remarks
Each observation is np.reshape(obs, shape), a view of the env's observation where NumPy gives one, as in
Python: disposing it does not free the env's array.
Reference: gymnasium/wrappers/transform_observation.py.
Constructors
ReshapeObservation(Env<TObs, TAct>, ReshapeObservationOptions)
Builds the instance from its options record: the properties set, the constructor's defaults for the rest.
public ReshapeObservation(Env<TObs, TAct> env, ReshapeObservationOptions options)
Parameters
envEnv<TObs, TAct>The env to wrap.
optionsReshapeObservationOptionsThe options.
Exceptions
- ArgumentNullException
Thrown when
optionsis null.- TypeError
Thrown when a required argument is unset, with Python's missing-argument message.
ReshapeObservation(Env<TObs, TAct>, long[])
Wraps env.
public ReshapeObservation(Env<TObs, TAct> env, long[] shape)
Parameters
envEnv<TObs, TAct>The env; its observation space must be a
Box.shapelong[]The new shape; its product must equal the space's (Gymnasium's check, which a
-1element therefore never passes).
Exceptions
- TypeError
Thrown when the space is no
Box(Gymnasium's message), orenvis null.- ArgumentNullException
Thrown when
shapeis null.- ValueError
Thrown when the products differ, or an element is neither positive nor -1, with Gymnasium's messages.
Properties
Shape
The new shape (shape).
public long[] Shape { get; }
Property Value
- long[]