mirror of
https://github.com/saymrwulf/stable-baselines3.git
synced 2026-07-29 20:14:17 +00:00
Rename to stable-baselines3
This commit is contained in:
parent
4a2c247592
commit
d542732c8d
72 changed files with 164 additions and 164 deletions
|
|
@ -4,7 +4,7 @@ omit =
|
|||
tests/*
|
||||
setup.py
|
||||
# Require graphical interface
|
||||
torchy_baselines/common/results_plotter.py
|
||||
stable_baselines3/common/results_plotter.py
|
||||
|
||||
[report]
|
||||
exclude_lines =
|
||||
|
|
|
|||
4
.github/ISSUE_TEMPLATE/issue-template.md
vendored
4
.github/ISSUE_TEMPLATE/issue-template.md
vendored
|
|
@ -13,7 +13,7 @@ If you are submitting a bug report, please fill in the following details.
|
|||
If your issue is related to a custom gym environment, please check it first using:
|
||||
|
||||
```python
|
||||
from torchy_baselines.common.env_checker import check_env
|
||||
from stable_baselines3.common.env_checker import check_env
|
||||
|
||||
env = CustomEnv(arg1, ...)
|
||||
# It will check your custom environment and output additional warnings if needed
|
||||
|
|
@ -30,7 +30,7 @@ Please use the [markdown code blocks](https://help.github.com/en/articles/creati
|
|||
for both code and stack traces.
|
||||
|
||||
```python
|
||||
from torchy_baselines import ...
|
||||
from stable_baselines3 import ...
|
||||
|
||||
```
|
||||
|
||||
|
|
|
|||
2
NOTICE
2
NOTICE
|
|
@ -1,4 +1,4 @@
|
|||
Large portion of the code of Torchy-Baselines (in `common/`) were ported from Stable-Baselines, a fork of OpenAI Baselines,
|
||||
Large portion of the code of Stable-Baselines3 (in `common/`) were ported from Stable-Baselines, a fork of OpenAI Baselines,
|
||||
both licensed under the MIT License:
|
||||
|
||||
before the fork (June 2018):
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
[](https://travis-ci.com/hill-a/stable-baselines) [](https://stable-baselines.readthedocs.io/en/master/?badge=master)
|
||||
|
||||
# Torchy Baselines
|
||||
# Stable Baselines3
|
||||
|
||||
PyTorch version of [Stable Baselines](https://github.com/hill-a/stable-baselines), a set of improved implementations of reinforcement learning algorithms.
|
||||
|
||||
|
|
@ -58,7 +58,7 @@ To cite this repository in publications:
|
|||
```
|
||||
@misc{torchy-baselines,
|
||||
author = {Raffin, Antonin and Hill, Ashley and Ernestus, Maximilian and Gleave, Adam and Kanervisto, Anssi and Dormann, Noah},
|
||||
title = {Torchy Baselines},
|
||||
title = {Stable Baselines3},
|
||||
year = {2019},
|
||||
publisher = {GitHub},
|
||||
journal = {GitHub repository},
|
||||
|
|
|
|||
20
docs/conf.py
20
docs/conf.py
|
|
@ -44,19 +44,19 @@ MOCK_MODULES = []
|
|||
sys.modules.update((mod_name, Mock()) for mod_name in MOCK_MODULES)
|
||||
|
||||
|
||||
import torchy_baselines
|
||||
import stable_baselines3
|
||||
|
||||
|
||||
# -- Project information -----------------------------------------------------
|
||||
|
||||
project = 'Torchy Baselines'
|
||||
copyright = '2020, Torchy Baselines'
|
||||
author = 'Torchy Baselines Contributors'
|
||||
project = 'Stable Baselines3'
|
||||
copyright = '2020, Stable Baselines3'
|
||||
author = 'Stable Baselines3 Contributors'
|
||||
|
||||
# The short X.Y version
|
||||
version = 'master (' + torchy_baselines.__version__ + ' )'
|
||||
version = 'master (' + stable_baselines3.__version__ + ' )'
|
||||
# The full version, including alpha/beta/rc tags
|
||||
release = torchy_baselines.__version__
|
||||
release = stable_baselines3.__version__
|
||||
|
||||
|
||||
# -- General configuration ---------------------------------------------------
|
||||
|
|
@ -179,8 +179,8 @@ latex_elements = {
|
|||
# (source start file, target name, title,
|
||||
# author, documentclass [howto, manual, or own class]).
|
||||
latex_documents = [
|
||||
(master_doc, 'TorchyBaselines.tex', 'Torchy Baselines Documentation',
|
||||
'Torchy Baselines Contributors', 'manual'),
|
||||
(master_doc, 'TorchyBaselines.tex', 'Stable Baselines3 Documentation',
|
||||
'Stable Baselines3 Contributors', 'manual'),
|
||||
]
|
||||
|
||||
|
||||
|
|
@ -189,7 +189,7 @@ latex_documents = [
|
|||
# One entry per manual page. List of tuples
|
||||
# (source start file, name, description, authors, manual section).
|
||||
man_pages = [
|
||||
(master_doc, 'torchybaselines', 'Torchy Baselines Documentation',
|
||||
(master_doc, 'torchybaselines', 'Stable Baselines3 Documentation',
|
||||
[author], 1)
|
||||
]
|
||||
|
||||
|
|
@ -200,7 +200,7 @@ man_pages = [
|
|||
# (source start file, target name, title, author,
|
||||
# dir menu entry, description, category)
|
||||
texinfo_documents = [
|
||||
(master_doc, 'TorchyBaselines', 'Torchy Baselines Documentation',
|
||||
(master_doc, 'TorchyBaselines', 'Stable Baselines3 Documentation',
|
||||
author, 'TorchyBaselines', 'One line description of project.',
|
||||
'Miscellaneous'),
|
||||
]
|
||||
|
|
|
|||
|
|
@ -12,9 +12,9 @@ Here is a quick example of how to train and run SAC on a Pendulum environment:
|
|||
|
||||
import gym
|
||||
|
||||
from torchy_baselines.sac.policies import MlpPolicy
|
||||
from torchy_baselines.common.vec_env import DummyVecEnv
|
||||
from torchy_baselines import SAC
|
||||
from stable_baselines3.sac.policies import MlpPolicy
|
||||
from stable_baselines3.common.vec_env import DummyVecEnv
|
||||
from stable_baselines3 import SAC
|
||||
|
||||
env = gym.make('Pendulum-v0')
|
||||
|
||||
|
|
@ -34,6 +34,6 @@ the policy is registered:
|
|||
|
||||
.. code-block:: python
|
||||
|
||||
from torchy_baselines import SAC
|
||||
from stable_baselines3 import SAC
|
||||
|
||||
model = SAC('MlpPolicy', 'Pendulum-v0').learn(10000)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
.. _vec_env:
|
||||
|
||||
.. automodule:: torchy_baselines.common.vec_env
|
||||
.. automodule:: stable_baselines3.common.vec_env
|
||||
|
||||
Vectorized Environments
|
||||
=======================
|
||||
|
|
|
|||
|
|
@ -3,10 +3,10 @@
|
|||
You can adapt this file completely to your liking, but it should at least
|
||||
contain the root `toctree` directive.
|
||||
|
||||
Welcome to Torchy Baselines docs! - Pytorch RL Baselines
|
||||
Welcome to Stable Baselines3 docs! - Pytorch RL Baselines
|
||||
========================================================
|
||||
|
||||
`Torchy Baselines <https://github.com/hill-a/stable-baselines>`_ is the PyTorch version of `Stable Baselines <https://github.com/hill-a/stable-baselines>`_,
|
||||
`Stable Baselines3 <https://github.com/hill-a/stable-baselines>`_ is the PyTorch version of `Stable Baselines <https://github.com/hill-a/stable-baselines>`_,
|
||||
a set of improved implementations of reinforcement learning algorithms.
|
||||
|
||||
RL Baselines Zoo (collection of pre-trained agents): https://github.com/araffin/rl-baselines-zoo
|
||||
|
|
@ -41,7 +41,7 @@ RL Baselines zoo also offers a simple interface to train, evaluate agents and do
|
|||
misc/changelog
|
||||
|
||||
|
||||
Citing Torchy Baselines
|
||||
Citing Stable Baselines3
|
||||
-----------------------
|
||||
To cite this project in publications:
|
||||
|
||||
|
|
@ -49,7 +49,7 @@ To cite this project in publications:
|
|||
|
||||
@misc{torchy-baselines,
|
||||
author = {Raffin, Antonin and Hill, Ashley and Ernestus, Maximilian and Gleave, Adam and Kanervisto, Anssi and Dormann, Noah},
|
||||
title = {Torchy Baselines},
|
||||
title = {Stable Baselines3},
|
||||
year = {2019},
|
||||
publisher = {GitHub},
|
||||
journal = {GitHub repository},
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ Pre-Release 0.2.0 (2020-02-14)
|
|||
|
||||
Breaking Changes:
|
||||
^^^^^^^^^^^^^^^^^
|
||||
- Python 2 support was dropped, Torchy Baselines now requires Python 3.6 or above
|
||||
- Python 2 support was dropped, Stable Baselines3 now requires Python 3.6 or above
|
||||
- Return type of ``evaluation.evaluate_policy()`` has been changed
|
||||
- Refactored the replay buffer to avoid transformation between PyTorch and NumPy
|
||||
- Created `OffPolicyRLModel` base class
|
||||
|
|
@ -160,7 +160,7 @@ New Features:
|
|||
Maintainers
|
||||
-----------
|
||||
|
||||
Torchy-Baselines is currently maintained by `Antonin Raffin`_ (aka `@araffin`_).
|
||||
Stable-Baselines3 is currently maintained by `Antonin Raffin`_ (aka `@araffin`_).
|
||||
|
||||
.. _Antonin Raffin: https://araffin.github.io/
|
||||
.. _@araffin: https://github.com/araffin
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
.. _a2c:
|
||||
|
||||
.. automodule:: torchy_baselines.a2c
|
||||
.. automodule:: stable_baselines3.a2c
|
||||
|
||||
|
||||
A2C
|
||||
|
|
@ -44,9 +44,9 @@ Train a A2C agent on `CartPole-v1` using 4 processes.
|
|||
|
||||
import gym
|
||||
|
||||
from torchy_baselines.common.policies import MlpPolicy
|
||||
from torchy_baselines.common import make_vec_env
|
||||
from torchy_baselines import A2C
|
||||
from stable_baselines3.common.policies import MlpPolicy
|
||||
from stable_baselines3.common import make_vec_env
|
||||
from stable_baselines3 import A2C
|
||||
|
||||
# Parallel environments
|
||||
env = make_vec_env('CartPole-v1', n_envs=4)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
.. _base_algo:
|
||||
|
||||
.. automodule:: torchy_baselines.common.base_class
|
||||
.. automodule:: stable_baselines3.common.base_class
|
||||
|
||||
|
||||
Base RL Class
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
.. _ppo2:
|
||||
|
||||
.. automodule:: torchy_baselines.ppo
|
||||
.. automodule:: stable_baselines3.ppo
|
||||
|
||||
PPO
|
||||
===
|
||||
|
|
@ -53,9 +53,9 @@ Train a PPO agent on `Pendulum-v0` using 4 processes.
|
|||
|
||||
import gym
|
||||
|
||||
from torchy_baselines.ppo.policies import MlpPolicy
|
||||
from torchy_baselines.common.vec_env import SubprocVecEnv
|
||||
from torchy_baselines import PPO
|
||||
from stable_baselines3.ppo.policies import MlpPolicy
|
||||
from stable_baselines3.common.vec_env import SubprocVecEnv
|
||||
from stable_baselines3 import PPO
|
||||
|
||||
# multiprocess environment
|
||||
n_cpu = 4
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
.. _sac:
|
||||
|
||||
.. automodule:: torchy_baselines.sac
|
||||
.. automodule:: stable_baselines3.sac
|
||||
|
||||
|
||||
SAC
|
||||
|
|
@ -14,7 +14,7 @@ A key feature of SAC, and a major difference with common RL algorithms, is that
|
|||
|
||||
.. warning::
|
||||
|
||||
The SAC model does not support ``torchy_baselines.common.policies`` because it uses double q-values
|
||||
The SAC model does not support ``stable_baselines3.common.policies`` because it uses double q-values
|
||||
and value estimation, as a result it must use its own policy models (see :ref:`sac_policies`).
|
||||
|
||||
|
||||
|
|
@ -72,9 +72,9 @@ Example
|
|||
import gym
|
||||
import numpy as np
|
||||
|
||||
from torchy_baselines.sac.policies import MlpPolicy
|
||||
from torchy_baselines.common.vec_env import DummyVecEnv
|
||||
from torchy_baselines import SAC
|
||||
from stable_baselines3.sac.policies import MlpPolicy
|
||||
from stable_baselines3.common.vec_env import DummyVecEnv
|
||||
from stable_baselines3 import SAC
|
||||
|
||||
env = gym.make('Pendulum-v0')
|
||||
env = DummyVecEnv([lambda: env])
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
.. _td3:
|
||||
|
||||
.. automodule:: torchy_baselines.td3
|
||||
.. automodule:: stable_baselines3.td3
|
||||
|
||||
|
||||
TD3
|
||||
|
|
@ -14,7 +14,7 @@ We recommend reading `OpenAI Spinning guide on TD3 <https://spinningup.openai.co
|
|||
|
||||
.. warning::
|
||||
|
||||
The TD3 model does not support ``torchy_baselines.common.policies`` because it uses double q-values
|
||||
The TD3 model does not support ``stable_baselines3.common.policies`` because it uses double q-values
|
||||
estimation, as a result it must use its own policy models (see :ref:`td3_policies`).
|
||||
|
||||
|
||||
|
|
@ -64,9 +64,9 @@ Example
|
|||
|
||||
import numpy as np
|
||||
|
||||
from torchy_baselines import TD3
|
||||
from torchy_baselines.td3.policies import MlpPolicy
|
||||
from torchy_baselines.common.noise import NormalActionNoise, OrnsteinUhlenbeckActionNoise
|
||||
from stable_baselines3 import TD3
|
||||
from stable_baselines3.td3.policies import MlpPolicy
|
||||
from stable_baselines3.common.noise import NormalActionNoise, OrnsteinUhlenbeckActionNoise
|
||||
|
||||
# The noise objects for TD3
|
||||
n_actions = env.action_space.shape[-1]
|
||||
|
|
|
|||
|
|
@ -18,4 +18,4 @@ filterwarnings =
|
|||
ignore::UserWarning:gym
|
||||
|
||||
[pytype]
|
||||
inputs = torchy_baselines
|
||||
inputs = stable_baselines3
|
||||
|
|
|
|||
6
setup.py
6
setup.py
|
|
@ -3,13 +3,13 @@ import sys
|
|||
import subprocess
|
||||
from setuptools import setup, find_packages
|
||||
|
||||
with open(os.path.join('torchy_baselines', 'version.txt'), 'r') as file_handler:
|
||||
with open(os.path.join('stable_baselines3', 'version.txt'), 'r') as file_handler:
|
||||
__version__ = file_handler.read()
|
||||
|
||||
|
||||
setup(name='torchy_baselines',
|
||||
setup(name='stable_baselines3',
|
||||
packages=[package for package in find_packages()
|
||||
if package.startswith('torchy_baselines')],
|
||||
if package.startswith('stable_baselines3')],
|
||||
install_requires=[
|
||||
'gym[classic_control]>=0.11',
|
||||
'numpy',
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
import os
|
||||
|
||||
from torchy_baselines.a2c import A2C
|
||||
from torchy_baselines.ppo import PPO
|
||||
from torchy_baselines.sac import SAC
|
||||
from torchy_baselines.td3 import TD3
|
||||
from stable_baselines3.a2c import A2C
|
||||
from stable_baselines3.ppo import PPO
|
||||
from stable_baselines3.sac import SAC
|
||||
from stable_baselines3.td3 import TD3
|
||||
|
||||
# Read version from file
|
||||
version_file = os.path.join(os.path.dirname(__file__), 'version.txt')
|
||||
2
stable_baselines3/a2c/__init__.py
Normal file
2
stable_baselines3/a2c/__init__.py
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
from stable_baselines3.a2c.a2c import A2C
|
||||
from stable_baselines3.ppo.policies import MlpPolicy
|
||||
|
|
@ -3,11 +3,11 @@ import torch.nn.functional as F
|
|||
from gym import spaces
|
||||
from typing import Type, Union, Callable, Optional, Dict, Any
|
||||
|
||||
from torchy_baselines.common import logger
|
||||
from torchy_baselines.common.type_aliases import GymEnv, MaybeCallback
|
||||
from torchy_baselines.common.utils import explained_variance
|
||||
from torchy_baselines.ppo.policies import PPOPolicy
|
||||
from torchy_baselines.ppo.ppo import PPO
|
||||
from stable_baselines3.common import logger
|
||||
from stable_baselines3.common.type_aliases import GymEnv, MaybeCallback
|
||||
from stable_baselines3.common.utils import explained_variance
|
||||
from stable_baselines3.ppo.policies import PPOPolicy
|
||||
from stable_baselines3.ppo.ppo import PPO
|
||||
|
||||
|
||||
class A2C(PPO):
|
||||
|
|
@ -11,17 +11,17 @@ import gym
|
|||
import torch as th
|
||||
import numpy as np
|
||||
|
||||
from torchy_baselines.common import logger
|
||||
from torchy_baselines.common.policies import BasePolicy, get_policy_from_name
|
||||
from torchy_baselines.common.utils import set_random_seed, get_schedule_fn, update_learning_rate, get_device
|
||||
from torchy_baselines.common.vec_env import DummyVecEnv, VecEnv, unwrap_vec_normalize, VecNormalize, VecTransposeImage
|
||||
from torchy_baselines.common.preprocessing import is_image_space
|
||||
from torchy_baselines.common.save_util import data_to_json, json_to_data, recursive_getattr, recursive_setattr
|
||||
from torchy_baselines.common.type_aliases import GymEnv, TensorDict, RolloutReturn, MaybeCallback
|
||||
from torchy_baselines.common.callbacks import BaseCallback, CallbackList, ConvertCallback, EvalCallback
|
||||
from torchy_baselines.common.monitor import Monitor
|
||||
from torchy_baselines.common.noise import ActionNoise
|
||||
from torchy_baselines.common.buffers import ReplayBuffer
|
||||
from stable_baselines3.common import logger
|
||||
from stable_baselines3.common.policies import BasePolicy, get_policy_from_name
|
||||
from stable_baselines3.common.utils import set_random_seed, get_schedule_fn, update_learning_rate, get_device
|
||||
from stable_baselines3.common.vec_env import DummyVecEnv, VecEnv, unwrap_vec_normalize, VecNormalize, VecTransposeImage
|
||||
from stable_baselines3.common.preprocessing import is_image_space
|
||||
from stable_baselines3.common.save_util import data_to_json, json_to_data, recursive_getattr, recursive_setattr
|
||||
from stable_baselines3.common.type_aliases import GymEnv, TensorDict, RolloutReturn, MaybeCallback
|
||||
from stable_baselines3.common.callbacks import BaseCallback, CallbackList, ConvertCallback, EvalCallback
|
||||
from stable_baselines3.common.monitor import Monitor
|
||||
from stable_baselines3.common.noise import ActionNoise
|
||||
from stable_baselines3.common.buffers import ReplayBuffer
|
||||
|
||||
|
||||
class BaseRLModel(ABC):
|
||||
|
|
@ -4,9 +4,9 @@ import numpy as np
|
|||
import torch as th
|
||||
from gym import spaces
|
||||
|
||||
from torchy_baselines.common.vec_env import VecNormalize
|
||||
from torchy_baselines.common.type_aliases import RolloutBufferSamples, ReplayBufferSamples
|
||||
from torchy_baselines.common.preprocessing import get_action_dim, get_obs_shape
|
||||
from stable_baselines3.common.vec_env import VecNormalize
|
||||
from stable_baselines3.common.type_aliases import RolloutBufferSamples, ReplayBufferSamples
|
||||
from stable_baselines3.common.preprocessing import get_action_dim, get_obs_shape
|
||||
|
||||
|
||||
class BaseBuffer(object):
|
||||
|
|
@ -7,12 +7,12 @@ from typing import Union, List, Dict, Any, Optional
|
|||
import gym
|
||||
import numpy as np
|
||||
|
||||
from torchy_baselines.common.vec_env import DummyVecEnv, VecEnv, sync_envs_normalization
|
||||
from torchy_baselines.common.evaluation import evaluate_policy
|
||||
from torchy_baselines.common.logger import Logger
|
||||
from stable_baselines3.common.vec_env import DummyVecEnv, VecEnv, sync_envs_normalization
|
||||
from stable_baselines3.common.evaluation import evaluate_policy
|
||||
from stable_baselines3.common.logger import Logger
|
||||
|
||||
if typing.TYPE_CHECKING:
|
||||
from torchy_baselines.common.base_class import BaseRLModel # pytype: disable=pyi-error
|
||||
from stable_baselines3.common.base_class import BaseRLModel # pytype: disable=pyi-error
|
||||
|
||||
|
||||
class BaseCallback(ABC):
|
||||
|
|
@ -6,7 +6,7 @@ import torch.nn as nn
|
|||
from torch.distributions import Normal, Categorical
|
||||
from gym import spaces
|
||||
|
||||
from torchy_baselines.common.preprocessing import get_action_dim
|
||||
from stable_baselines3.common.preprocessing import get_action_dim
|
||||
|
||||
|
||||
class Distribution(object):
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
# Copied from stable_baselines
|
||||
import numpy as np
|
||||
|
||||
from torchy_baselines.common.vec_env import VecEnv
|
||||
from stable_baselines3.common.vec_env import VecEnv
|
||||
|
||||
|
||||
def evaluate_policy(model, env, n_eval_episodes=10, deterministic=True,
|
||||
|
|
@ -5,7 +5,7 @@ from gym import Env
|
|||
from gym.spaces import Discrete, MultiDiscrete, MultiBinary, Box
|
||||
|
||||
|
||||
from torchy_baselines.common.type_aliases import GymStepReturn, GymObs
|
||||
from stable_baselines3.common.type_aliases import GymStepReturn, GymObs
|
||||
|
||||
|
||||
class IdentityEnv(Env):
|
||||
|
|
@ -7,9 +7,9 @@ import torch as th
|
|||
import torch.nn as nn
|
||||
import numpy as np
|
||||
|
||||
from torchy_baselines.common.preprocessing import preprocess_obs, get_flattened_obs_dim, is_image_space
|
||||
from torchy_baselines.common.utils import get_device
|
||||
from torchy_baselines.common.vec_env import VecTransposeImage
|
||||
from stable_baselines3.common.preprocessing import preprocess_obs, get_flattened_obs_dim, is_image_space
|
||||
from stable_baselines3.common.utils import get_device
|
||||
from stable_baselines3.common.vec_env import VecTransposeImage
|
||||
|
||||
|
||||
class BaseFeaturesExtractor(nn.Module):
|
||||
|
|
@ -6,7 +6,7 @@ import pandas as pd
|
|||
# matplotlib.use('TkAgg') # Can change to 'Agg' for non-interactive mode
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
from torchy_baselines.common.monitor import load_results
|
||||
from stable_baselines3.common.monitor import load_results
|
||||
|
||||
|
||||
X_TIMESTEPS = 'timesteps'
|
||||
|
|
@ -7,8 +7,8 @@ import numpy as np
|
|||
import torch as th
|
||||
import gym
|
||||
|
||||
from torchy_baselines.common.vec_env import VecEnv
|
||||
from torchy_baselines.common.callbacks import BaseCallback
|
||||
from stable_baselines3.common.vec_env import VecEnv
|
||||
from stable_baselines3.common.callbacks import BaseCallback
|
||||
|
||||
|
||||
GymEnv = Union[gym.Env, VecEnv]
|
||||
|
|
@ -3,17 +3,17 @@ import typing
|
|||
from typing import Optional, Union
|
||||
from copy import deepcopy
|
||||
|
||||
from torchy_baselines.common.vec_env.base_vec_env import (AlreadySteppingError, NotSteppingError,
|
||||
from stable_baselines3.common.vec_env.base_vec_env import (AlreadySteppingError, NotSteppingError,
|
||||
VecEnv, VecEnvWrapper, CloudpickleWrapper)
|
||||
from torchy_baselines.common.vec_env.dummy_vec_env import DummyVecEnv
|
||||
from torchy_baselines.common.vec_env.subproc_vec_env import SubprocVecEnv
|
||||
from torchy_baselines.common.vec_env.vec_frame_stack import VecFrameStack
|
||||
from torchy_baselines.common.vec_env.vec_normalize import VecNormalize
|
||||
from torchy_baselines.common.vec_env.vec_transpose import VecTransposeImage
|
||||
from stable_baselines3.common.vec_env.dummy_vec_env import DummyVecEnv
|
||||
from stable_baselines3.common.vec_env.subproc_vec_env import SubprocVecEnv
|
||||
from stable_baselines3.common.vec_env.vec_frame_stack import VecFrameStack
|
||||
from stable_baselines3.common.vec_env.vec_normalize import VecNormalize
|
||||
from stable_baselines3.common.vec_env.vec_transpose import VecTransposeImage
|
||||
|
||||
# Avoid circular import
|
||||
if typing.TYPE_CHECKING:
|
||||
from torchy_baselines.common.type_aliases import GymEnv
|
||||
from stable_baselines3.common.type_aliases import GymEnv
|
||||
|
||||
|
||||
def unwrap_vec_normalize(env: Union['GymEnv', VecEnv]) -> Optional[VecNormalize]:
|
||||
|
|
@ -3,8 +3,8 @@ from copy import deepcopy
|
|||
|
||||
import numpy as np
|
||||
|
||||
from torchy_baselines.common.vec_env.base_vec_env import VecEnv
|
||||
from torchy_baselines.common.vec_env.util import copy_obs_dict, dict_to_obs, obs_space_info
|
||||
from stable_baselines3.common.vec_env.base_vec_env import VecEnv
|
||||
from stable_baselines3.common.vec_env.util import copy_obs_dict, dict_to_obs, obs_space_info
|
||||
|
||||
|
||||
class DummyVecEnv(VecEnv):
|
||||
|
|
@ -4,7 +4,7 @@ from collections import OrderedDict
|
|||
import gym
|
||||
import numpy as np
|
||||
|
||||
from torchy_baselines.common.vec_env.base_vec_env import VecEnv, CloudpickleWrapper
|
||||
from stable_baselines3.common.vec_env.base_vec_env import VecEnv, CloudpickleWrapper
|
||||
|
||||
|
||||
def _worker(remote, parent_remote, env_fn_wrapper):
|
||||
|
|
@ -3,7 +3,7 @@ import warnings
|
|||
import numpy as np
|
||||
from gym import spaces
|
||||
|
||||
from torchy_baselines.common.vec_env.base_vec_env import VecEnv, VecEnvWrapper
|
||||
from stable_baselines3.common.vec_env.base_vec_env import VecEnv, VecEnvWrapper
|
||||
|
||||
|
||||
class VecFrameStack(VecEnvWrapper):
|
||||
|
|
@ -2,8 +2,8 @@ import pickle
|
|||
|
||||
import numpy as np
|
||||
|
||||
from torchy_baselines.common.vec_env.base_vec_env import VecEnvWrapper
|
||||
from torchy_baselines.common.running_mean_std import RunningMeanStd
|
||||
from stable_baselines3.common.vec_env.base_vec_env import VecEnvWrapper
|
||||
from stable_baselines3.common.running_mean_std import RunningMeanStd
|
||||
|
||||
|
||||
class VecNormalize(VecEnvWrapper):
|
||||
|
|
@ -2,11 +2,11 @@ import typing
|
|||
import numpy as np
|
||||
from gym import spaces
|
||||
|
||||
from torchy_baselines.common.vec_env.base_vec_env import VecEnv, VecEnvWrapper
|
||||
from torchy_baselines.common.preprocessing import is_image_space
|
||||
from stable_baselines3.common.vec_env.base_vec_env import VecEnv, VecEnvWrapper
|
||||
from stable_baselines3.common.preprocessing import is_image_space
|
||||
|
||||
if typing.TYPE_CHECKING:
|
||||
from torchy_baselines.common.type_aliases import GymStepReturn
|
||||
from stable_baselines3.common.type_aliases import GymStepReturn
|
||||
|
||||
|
||||
class VecTransposeImage(VecEnvWrapper):
|
||||
2
stable_baselines3/ppo/__init__.py
Normal file
2
stable_baselines3/ppo/__init__.py
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
from stable_baselines3.ppo.ppo import PPO
|
||||
from stable_baselines3.ppo.policies import MlpPolicy
|
||||
|
|
@ -6,10 +6,10 @@ import torch as th
|
|||
import torch.nn as nn
|
||||
import numpy as np
|
||||
|
||||
from torchy_baselines.common.policies import (BasePolicy, register_policy, MlpExtractor,
|
||||
from stable_baselines3.common.policies import (BasePolicy, register_policy, MlpExtractor,
|
||||
create_sde_features_extractor, NatureCNN,
|
||||
BaseFeaturesExtractor, FlattenExtractor)
|
||||
from torchy_baselines.common.distributions import (make_proba_distribution, Distribution,
|
||||
from stable_baselines3.common.distributions import (make_proba_distribution, Distribution,
|
||||
DiagGaussianDistribution, CategoricalDistribution,
|
||||
StateDependentNoiseDistribution)
|
||||
|
||||
|
|
@ -14,14 +14,14 @@ import torch.nn.functional as F
|
|||
# SummaryWriter = None
|
||||
import numpy as np
|
||||
|
||||
from torchy_baselines.common import logger
|
||||
from torchy_baselines.common.base_class import BaseRLModel
|
||||
from torchy_baselines.common.type_aliases import GymEnv, MaybeCallback
|
||||
from torchy_baselines.common.buffers import RolloutBuffer
|
||||
from torchy_baselines.common.utils import explained_variance, get_schedule_fn
|
||||
from torchy_baselines.common.vec_env import VecEnv
|
||||
from torchy_baselines.common.callbacks import BaseCallback
|
||||
from torchy_baselines.ppo.policies import PPOPolicy
|
||||
from stable_baselines3.common import logger
|
||||
from stable_baselines3.common.base_class import BaseRLModel
|
||||
from stable_baselines3.common.type_aliases import GymEnv, MaybeCallback
|
||||
from stable_baselines3.common.buffers import RolloutBuffer
|
||||
from stable_baselines3.common.utils import explained_variance, get_schedule_fn
|
||||
from stable_baselines3.common.vec_env import VecEnv
|
||||
from stable_baselines3.common.callbacks import BaseCallback
|
||||
from stable_baselines3.ppo.policies import PPOPolicy
|
||||
|
||||
|
||||
class PPO(BaseRLModel):
|
||||
2
stable_baselines3/sac/__init__.py
Normal file
2
stable_baselines3/sac/__init__.py
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
from stable_baselines3.sac.sac import SAC
|
||||
from stable_baselines3.sac.policies import MlpPolicy
|
||||
|
|
@ -4,11 +4,11 @@ import gym
|
|||
import torch as th
|
||||
import torch.nn as nn
|
||||
|
||||
from torchy_baselines.common.preprocessing import get_action_dim
|
||||
from torchy_baselines.common.policies import (BasePolicy, register_policy, create_mlp,
|
||||
from stable_baselines3.common.preprocessing import get_action_dim
|
||||
from stable_baselines3.common.policies import (BasePolicy, register_policy, create_mlp,
|
||||
create_sde_features_extractor, NatureCNN,
|
||||
BaseFeaturesExtractor, FlattenExtractor)
|
||||
from torchy_baselines.common.distributions import SquashedDiagGaussianDistribution, StateDependentNoiseDistribution
|
||||
from stable_baselines3.common.distributions import SquashedDiagGaussianDistribution, StateDependentNoiseDistribution
|
||||
|
||||
# CAP the standard deviation of the actor
|
||||
LOG_STD_MAX = 2
|
||||
|
|
@ -4,11 +4,11 @@ import torch as th
|
|||
import torch.nn.functional as F
|
||||
import numpy as np
|
||||
|
||||
from torchy_baselines.common import logger
|
||||
from torchy_baselines.common.base_class import OffPolicyRLModel
|
||||
from torchy_baselines.common.type_aliases import GymEnv, MaybeCallback
|
||||
from torchy_baselines.common.noise import ActionNoise
|
||||
from torchy_baselines.sac.policies import SACPolicy
|
||||
from stable_baselines3.common import logger
|
||||
from stable_baselines3.common.base_class import OffPolicyRLModel
|
||||
from stable_baselines3.common.type_aliases import GymEnv, MaybeCallback
|
||||
from stable_baselines3.common.noise import ActionNoise
|
||||
from stable_baselines3.sac.policies import SACPolicy
|
||||
|
||||
|
||||
class SAC(OffPolicyRLModel):
|
||||
2
stable_baselines3/td3/__init__.py
Normal file
2
stable_baselines3/td3/__init__.py
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
from stable_baselines3.td3.td3 import TD3
|
||||
from stable_baselines3.td3.policies import MlpPolicy
|
||||
|
|
@ -4,11 +4,11 @@ import gym
|
|||
import torch as th
|
||||
import torch.nn as nn
|
||||
|
||||
from torchy_baselines.common.preprocessing import get_action_dim
|
||||
from torchy_baselines.common.policies import (BasePolicy, register_policy, create_mlp,
|
||||
from stable_baselines3.common.preprocessing import get_action_dim
|
||||
from stable_baselines3.common.policies import (BasePolicy, register_policy, create_mlp,
|
||||
create_sde_features_extractor, NatureCNN,
|
||||
BaseFeaturesExtractor, FlattenExtractor)
|
||||
from torchy_baselines.common.distributions import StateDependentNoiseDistribution
|
||||
from stable_baselines3.common.distributions import StateDependentNoiseDistribution
|
||||
|
||||
|
||||
class Actor(BasePolicy):
|
||||
|
|
@ -2,11 +2,11 @@ import torch as th
|
|||
import torch.nn.functional as F
|
||||
from typing import List, Tuple, Type, Union, Callable, Optional, Dict, Any
|
||||
|
||||
from torchy_baselines.common import logger
|
||||
from torchy_baselines.common.base_class import OffPolicyRLModel
|
||||
from torchy_baselines.common.noise import ActionNoise
|
||||
from torchy_baselines.common.type_aliases import GymEnv, MaybeCallback
|
||||
from torchy_baselines.td3.policies import TD3Policy
|
||||
from stable_baselines3.common import logger
|
||||
from stable_baselines3.common.base_class import OffPolicyRLModel
|
||||
from stable_baselines3.common.noise import ActionNoise
|
||||
from stable_baselines3.common.type_aliases import GymEnv, MaybeCallback
|
||||
from stable_baselines3.td3.policies import TD3Policy
|
||||
|
||||
|
||||
class TD3(OffPolicyRLModel):
|
||||
|
|
@ -4,8 +4,8 @@ import shutil
|
|||
import pytest
|
||||
import gym
|
||||
|
||||
from torchy_baselines import A2C, PPO, SAC, TD3
|
||||
from torchy_baselines.common.callbacks import (CallbackList, CheckpointCallback, EvalCallback,
|
||||
from stable_baselines3 import A2C, PPO, SAC, TD3
|
||||
from stable_baselines3.common.callbacks import (CallbackList, CheckpointCallback, EvalCallback,
|
||||
EveryNTimesteps, StopTrainingOnRewardThreshold)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ import os
|
|||
import numpy as np
|
||||
import pytest
|
||||
|
||||
from torchy_baselines import A2C, PPO, SAC, TD3
|
||||
from torchy_baselines.common.identity_env import FakeImageEnv
|
||||
from stable_baselines3 import A2C, PPO, SAC, TD3
|
||||
from stable_baselines3.common.identity_env import FakeImageEnv
|
||||
|
||||
SAVE_PATH = './cnn_model.zip'
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import pytest
|
||||
import torch as th
|
||||
|
||||
from torchy_baselines import A2C, PPO, SAC, TD3
|
||||
from stable_baselines3 import A2C, PPO, SAC, TD3
|
||||
|
||||
|
||||
@pytest.mark.parametrize('net_arch', [
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
import pytest
|
||||
import torch as th
|
||||
|
||||
from torchy_baselines import A2C, PPO
|
||||
from torchy_baselines.common.distributions import (DiagGaussianDistribution, TanhBijector,
|
||||
from stable_baselines3 import A2C, PPO
|
||||
from stable_baselines3.common.distributions import (DiagGaussianDistribution, TanhBijector,
|
||||
StateDependentNoiseDistribution,
|
||||
CategoricalDistribution, SquashedDiagGaussianDistribution)
|
||||
from torchy_baselines.common.utils import set_random_seed
|
||||
from stable_baselines3.common.utils import set_random_seed
|
||||
|
||||
|
||||
N_ACTIONS = 2
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
import numpy as np
|
||||
import pytest
|
||||
|
||||
from torchy_baselines import A2C, PPO, SAC, TD3
|
||||
from torchy_baselines.common.identity_env import IdentityEnvBox, IdentityEnv
|
||||
from torchy_baselines.common.evaluation import evaluate_policy
|
||||
from torchy_baselines.common.noise import NormalActionNoise
|
||||
from stable_baselines3 import A2C, PPO, SAC, TD3
|
||||
from stable_baselines3.common.identity_env import IdentityEnvBox, IdentityEnv
|
||||
from stable_baselines3.common.evaluation import evaluate_policy
|
||||
from stable_baselines3.common.noise import NormalActionNoise
|
||||
|
||||
|
||||
@pytest.mark.parametrize("model_class", [A2C, PPO])
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import shutil
|
|||
import pytest
|
||||
import numpy as np
|
||||
|
||||
from torchy_baselines.common.logger import (make_output_format, read_csv, read_json, DEBUG, ScopedConfigure,
|
||||
from stable_baselines3.common.logger import (make_output_format, read_csv, read_json, DEBUG, ScopedConfigure,
|
||||
info, debug, set_level, configure, logkv, logkvs,
|
||||
dumpkvs, logkv_mean, warn, error, reset)
|
||||
|
||||
|
|
@ -18,7 +18,7 @@ KEY_VALUES = {
|
|||
"g": np.array([[[1]]]),
|
||||
}
|
||||
|
||||
LOG_DIR = '/tmp/torchy_baselines/'
|
||||
LOG_DIR = '/tmp/stable_baselines3/'
|
||||
|
||||
|
||||
def test_main():
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import os
|
|||
import pandas
|
||||
import gym
|
||||
|
||||
from torchy_baselines.common.monitor import Monitor, get_monitor_files, load_results
|
||||
from stable_baselines3.common.monitor import Monitor, get_monitor_files, load_results
|
||||
|
||||
|
||||
def test_monitor(tmp_path):
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
import gym
|
||||
import pytest
|
||||
|
||||
from torchy_baselines import A2C, PPO, SAC, TD3
|
||||
from torchy_baselines.common.vec_env import DummyVecEnv
|
||||
from stable_baselines3 import A2C, PPO, SAC, TD3
|
||||
from stable_baselines3.common.vec_env import DummyVecEnv
|
||||
|
||||
MODEL_LIST = [
|
||||
PPO,
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
import numpy as np
|
||||
import pytest
|
||||
|
||||
from torchy_baselines import A2C, PPO, SAC, TD3
|
||||
from torchy_baselines.common.noise import NormalActionNoise, OrnsteinUhlenbeckActionNoise
|
||||
from stable_baselines3 import A2C, PPO, SAC, TD3
|
||||
from stable_baselines3.common.noise import NormalActionNoise, OrnsteinUhlenbeckActionNoise
|
||||
|
||||
normal_action_noise = NormalActionNoise(np.zeros(1), 0.1 * np.ones(1))
|
||||
|
||||
|
|
|
|||
|
|
@ -5,10 +5,10 @@ import pytest
|
|||
import numpy as np
|
||||
import torch as th
|
||||
|
||||
from torchy_baselines import A2C, PPO, SAC, TD3
|
||||
from torchy_baselines.common.identity_env import IdentityEnvBox
|
||||
from torchy_baselines.common.vec_env import DummyVecEnv
|
||||
from torchy_baselines.common.identity_env import FakeImageEnv
|
||||
from stable_baselines3 import A2C, PPO, SAC, TD3
|
||||
from stable_baselines3.common.identity_env import IdentityEnvBox
|
||||
from stable_baselines3.common.vec_env import DummyVecEnv
|
||||
from stable_baselines3.common.identity_env import FakeImageEnv
|
||||
|
||||
|
||||
MODEL_LIST = [
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import pytest
|
|||
import torch as th
|
||||
from torch.distributions import Normal
|
||||
|
||||
from torchy_baselines import A2C, TD3, SAC, PPO
|
||||
from stable_baselines3 import A2C, TD3, SAC, PPO
|
||||
|
||||
|
||||
def test_state_dependent_exploration_grad():
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import pytest
|
|||
import gym
|
||||
import numpy as np
|
||||
|
||||
from torchy_baselines.common.vec_env import DummyVecEnv, SubprocVecEnv, VecNormalize, VecFrameStack
|
||||
from stable_baselines3.common.vec_env import DummyVecEnv, SubprocVecEnv, VecNormalize, VecFrameStack
|
||||
|
||||
N_ENVS = 3
|
||||
VEC_ENV_CLASSES = [DummyVecEnv, SubprocVecEnv]
|
||||
|
|
|
|||
|
|
@ -2,9 +2,9 @@ import gym
|
|||
import pytest
|
||||
import numpy as np
|
||||
|
||||
from torchy_baselines.common.running_mean_std import RunningMeanStd
|
||||
from torchy_baselines.common.vec_env import DummyVecEnv, VecNormalize, VecFrameStack, sync_envs_normalization, unwrap_vec_normalize
|
||||
from torchy_baselines import SAC, TD3
|
||||
from stable_baselines3.common.running_mean_std import RunningMeanStd
|
||||
from stable_baselines3.common.vec_env import DummyVecEnv, VecNormalize, VecFrameStack, sync_envs_normalization, unwrap_vec_normalize
|
||||
from stable_baselines3 import SAC, TD3
|
||||
|
||||
ENV_ID = 'Pendulum-v0'
|
||||
|
||||
|
|
|
|||
|
|
@ -1,2 +0,0 @@
|
|||
from torchy_baselines.a2c.a2c import A2C
|
||||
from torchy_baselines.ppo.policies import MlpPolicy
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
from torchy_baselines.ppo.ppo import PPO
|
||||
from torchy_baselines.ppo.policies import MlpPolicy
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
from torchy_baselines.sac.sac import SAC
|
||||
from torchy_baselines.sac.policies import MlpPolicy
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
from torchy_baselines.td3.td3 import TD3
|
||||
from torchy_baselines.td3.policies import MlpPolicy
|
||||
Loading…
Reference in a new issue