Table of Contents

Class FlattenObservation<TObs, TAct>

Namespace
Gym.Wrappers
Assembly
Gym.dll

Flattens every observation into a 1-D array (spaces.utils.flatten), with the flattened space (flatten_space) as the observation space, as Gymnasium's FlattenObservation does: a Dict or Tuple of arrays becomes one array, a Discrete a one-hot vector.

public class FlattenObservation<TObs, TAct> : TransformObservation<NDArray, TObs, TAct>, IDynamicAttributes, IWrapper, IEnv, IDisposable, IRecordConstructorArgs

Type Parameters

TObs

The env's observation type.

TAct

The action type, passed through.

Inheritance
Env<NDArray, TAct>
Wrapper<NDArray, TAct, TObs, TAct>
FlattenObservation<TObs, TAct>
Implements
Inherited Members
Extension Methods

Remarks

Typed for array results: a space whose flat form is not an array (Graph, Sequence, whose flatten_space keeps them composite) is refused at construction with a TypeError rather than returning a non-array observation.

Reference: gymnasium/wrappers/transform_observation.py.

Constructors

FlattenObservation(Env<TObs, TAct>)

Wraps env.

public FlattenObservation(Env<TObs, TAct> env)

Parameters

env Env<TObs, TAct>

The env.

Exceptions

TypeError

Thrown when env is null, or its space's flat form is not an array.

FlattenObservation(Env<TObs, TAct>, FlattenObservationOptions)

Builds the instance from its options record: the properties set, the constructor's defaults for the rest.

public FlattenObservation(Env<TObs, TAct> env, FlattenObservationOptions options)

Parameters

env Env<TObs, TAct>

The env to wrap.

options FlattenObservationOptions

The options.

Exceptions

ArgumentNullException

Thrown when options is null.