> ## Documentation Index
> Fetch the complete documentation index at: https://docs.coreweave.com/llms.txt
> Use this file to discover all available pages before exploring further.

> W&B を OpenAI Gym と統合して、強化学習の実験をトラッキングし、エピソードのパフォーマンス動画を記録します。

# OpenAI Gym

<Note>
  "2021 年以降 Gym をメンテナンスしてきたチームは、今後の開発をすべて [Gymnasium](https://github.com/Farama-Foundation/Gymnasium) に移行しました。Gymnasium は Gym のドロップイン代替 (import gymnasium as gym) であり、Gym は今後更新を受け取ることはありません。" ([Source](https://github.com/openai/gym#the-team-that-has-been-maintaining-gym-since-2021-has-moved-all-future-development-to-gymnasium-a-drop-in-replacement-for-gym-import-gymnasium-as-gym-and-gym-will-not-be-receiving-any-future-updates-please-switch-over-to-gymnasium-as-soon-as-youre-able-to-do-so-if-youd-like-to-read-more-about-the-story-behind-this-switch-please-check-out-this-blog-post))

  Gym はすでにメンテナンスされていないプロジェクトであるため、Gymnasium との統合をお試しください。
</Note>

このページでは、W\&B を [OpenAI Gym](https://github.com/openai/gym) とともに使用して、強化学習環境の動画を自動的に取得する方法について説明します。W\&B でエージェントの動作と実験のメトリクスを並べて確認できます。

OpenAI Gym を使用する場合、W\&B は `gym.wrappers.Monitor` によって生成された環境の動画を自動的にログします。これを有効にするには、[`wandb.init()`](/ja/products/wandb/ref/python/functions/init) の `monitor_gym` キーワード引数を `True` に設定するか、`wandb.gym.monitor()` を呼び出します。

gym 統合は軽量です。`gym` からログされる動画ファイルの名前を[確認](https://github.com/wandb/wandb/blob/master/wandb/integration/gym/__init__.py#L15)し、それにちなんで名前を付け、一致するものがない場合は `"videos"` にフォールバックします。より細かい制御が必要な場合は、手動で[動画をログ](/ja/products/wandb/track/log/media)できます。

[CleanRL](https://github.com/vwxyzjn/cleanrl) による [OpenRL Benchmark](https://wandb.me/openrl-benchmark-report) は、OpenAI Gym のサンプルでこの統合を使用しています。gym を W\&B とともに使用する方法を示すソースコード ([特定の run で使用されたコード](https://forge.coreweave.com/wandb/cleanrl/cleanrl.benchmark/runs/2jrqfugg/code?workspace=user-costa-huang)を含む) をご覧いただけます。

<Frame>
  <img src="https://mintcdn.com/coreweave-dbfa0e8d/3Dv_sw2eg8feUJlx/products/wandb/_media/open_ai_report_example.png?fit=max&auto=format&n=3Dv_sw2eg8feUJlx&q=85&s=ae0ce3cdf2081211ac8cce80c68a1900" alt="OpenAI Gym ダッシュボード" width="1048" height="815" data-path="products/wandb/_media/open_ai_report_example.png" />
</Frame>
