Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Farama Foundation Gymnasium Vector Wrappers Init

From Leeroopedia
Revision as of 12:38, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/Farama_Foundation_Gymnasium_Vector_Wrappers_Init.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Knowledge Sources
Domains Reinforcement_Learning, Wrappers
Last Updated 2026-02-15 03:00 GMT

Overview

The public API index for the Gymnasium vector wrappers package, providing a centralized import point for all vector environment wrapper classes with lazy loading for framework-specific wrappers.

Description

This __init__.py module serves as the entry point for the gymnasium.wrappers.vector package. It imports and re-exports all vector environment wrapper classes organized by category:

Vector-Only Wrappers: VectorizeTransformObservation, VectorizeTransformAction, VectorizeTransformReward, DictInfoToList

Observation Wrappers: TransformObservation, FilterObservation, FlattenObservation, GrayscaleObservation, ResizeObservation, ReshapeObservation, RescaleObservation, DtypeObservation, NormalizeObservation

Action Wrappers: TransformAction, ClipAction, RescaleAction

Reward Wrappers: TransformReward, ClipReward, NormalizeReward

Common Wrappers: RecordEpisodeStatistics

Rendering Wrappers: RecordVideo, HumanRendering

Conversion Wrappers (lazy-loaded): ArrayConversion, JaxToNumpy, JaxToTorch, NumpyToTorch

Like the single-environment wrappers package, conversion wrappers are loaded lazily via __getattr__ to avoid importing jax or torch at module load time.

Usage

Import vector wrappers from gymnasium.wrappers.vector. These wrappers are designed to work with VectorEnv instances created via gym.make_vec().

Code Reference

Source Location

Signature

# Module-level __getattr__ for lazy loading
def __getattr__(wrapper_name: str):
    """Load a wrapper by name, with lazy loading for framework-specific wrappers."""
    ...

Import

from gymnasium.wrappers.vector import (
    TransformObservation, FilterObservation, FlattenObservation,
    NormalizeObservation, NormalizeReward,
    TransformAction, ClipAction, RescaleAction,
    TransformReward, ClipReward,
    DictInfoToList, RecordEpisodeStatistics,
    RecordVideo, HumanRendering,
    VectorizeTransformObservation, VectorizeTransformAction, VectorizeTransformReward,
)
# Lazy-loaded:
from gymnasium.wrappers.vector import ArrayConversion, JaxToNumpy, JaxToTorch, NumpyToTorch

I/O Contract

Exported Symbols

Category Wrappers
Vector-Only VectorizeTransformObservation, VectorizeTransformAction, VectorizeTransformReward, DictInfoToList
Observation TransformObservation, FilterObservation, FlattenObservation, GrayscaleObservation, ResizeObservation, ReshapeObservation, RescaleObservation, DtypeObservation, NormalizeObservation
Action TransformAction, ClipAction, RescaleAction
Reward TransformReward, ClipReward, NormalizeReward
Common RecordEpisodeStatistics
Rendering RecordVideo, HumanRendering
Conversion ArrayConversion, JaxToNumpy, JaxToTorch, NumpyToTorch

Usage Examples

import gymnasium as gym
from gymnasium.wrappers.vector import NormalizeObservation, NormalizeReward, ClipAction

# Create a vectorized environment and wrap it
envs = gym.make_vec("CartPole-v1", num_envs=4, vectorization_mode="sync")
envs = NormalizeObservation(envs)
envs = NormalizeReward(envs)

obs, info = envs.reset(seed=123)
obs, reward, terminated, truncated, info = envs.step(envs.action_space.sample())
envs.close()

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment