.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/demo_agents/demo_SAC.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_demo_agents_demo_SAC.py: ============================= SAC Soft Actor-Critic ============================= This script shows how to train a SAC agent on a Pendulum environment. .. GENERATED FROM PYTHON SOURCE LINES 8-44 .. code-block:: python3 import time import gymnasium as gym from rlberry_research.agents.torch.sac import SACAgent from rlberry_research.envs import Pendulum from rlberry.manager import ExperimentManager def env_ctor(env, wrap_spaces=True): return env # Setup agent parameters env_name = "Pendulum" fit_budget = int(2e5) agent_name = f"{env_name}_{fit_budget}_{int(time.time())}" # Setup environment parameters env = Pendulum() env = gym.wrappers.TimeLimit(env, max_episode_steps=200) env = gym.wrappers.RecordEpisodeStatistics(env) env_kwargs = dict(env=env) # Create agent instance xp_manager = ExperimentManager( SACAgent, (env_ctor, env_kwargs), fit_budget=fit_budget, n_fit=1, enable_tensorboard=True, agent_name=agent_name, ) # Start training xp_manager.fit() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.000 seconds) .. _sphx_glr_download_auto_examples_demo_agents_demo_SAC.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: demo_SAC.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: demo_SAC.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_