ML Community Day is November 9! Join us for updates from TensorFlow, JAX, and more Learn more

tf_agents.environments.gym_wrapper.spec_from_gym_space

Converts gym spaces into array specs.

Gym does not properly define dtypes for spaces. By default all spaces set their type to float64 even though observations do not always return this type. See: https://github.com/openai/gym/issues/527

To handle this we allow a dtype_map for setting default types for mapping spaces to specs.

observations. Not sure that we have a need for this yet.

space gym.Space to turn into a spec.
dtype_map A dict from spaces to dtypes to use as the default dtype.
simplify_box_bounds Whether to replace bounds of Box space that are arrays with identical values with one number and rely on broadcasting.
name Name of the spec.

A BoundedArraySpec nest mirroring the given space structure.

ValueError If there is an unknown space type.