Commit graph

382 commits

Author SHA1 Message Date
Sidney Tio
d6ddee9366
Add evalcallback example (#1468)
* Moved 'Monitoring Training' to subsubsection of 'Using callbacks'

* Added EvalCallback example

* Updated Changelogs

* Edited the language

* Moved subsection headers up one level

* added make_vec_env into Evalcallback example

* Added parameters to the top for readability

* Added note on multiple training environments

* Added more clarity to eval_freq note

* Apply suggestions from code review

---------

Co-authored-by: Antonin RAFFIN <antonin.raffin@ensta.org>
2023-05-02 18:02:36 +02:00
Übertreiber
4f9805eeb8
Fix overly relaxed version requirement on NumPy (#1472)
Since commit 489b1fda, this package has been using
`numpy.typing.DTypeLike`, which was only added in [NumPy 1.20][1].

[1]: https://numpy.org/doc/stable/release/1.20.0-notes.html#numpy-is-now-typed

Co-authored-by: troiganto <troiganto@proton.me>
Co-authored-by: Antonin RAFFIN <antonin.raffin@ensta.org>
2023-04-27 19:07:53 +02:00
Tobias Rohrer
6cbb2c9303
Fix DQN target update interval for multi-env (#1463)
* Calculating target update interval per environment in `_on_step()`. See GitHub issue #1373

* Added changelog entry and changed test comment

* Added requested changes from code review

* Update version

---------

Co-authored-by: Antonin RAFFIN <antonin.raffin@ensta.org>
2023-04-27 18:35:33 +02:00
Lei He
dc09d81f9c
Added UAV_Navigation_DRL_AirSim to the project page (#1462)
* Update changelog.rst

* Update projects.rst

* Update grammar and fix doc build

---------

Co-authored-by: Antonin RAFFIN <antonin.raffin@ensta.org>
2023-04-20 23:12:57 +02:00
Antonin RAFFIN
96526ed08a
Update issue templates and env infos (#1451)
* Update issue templates and env infos

* Fix pytype
2023-04-14 13:50:14 +02:00
Antonin RAFFIN
40e0b9d2c8
Add Gymnasium support (#1327)
* Fix failing set_env test

* Fix test failiing due to deprectation of env.seed

* Adjust mean reward threshold in failing test

* Fix her test failing due to rng

* Change seed and revert reward threshold to 90

* Pin gym version

* Make VecEnv compatible with gym seeding change

* Revert change to VecEnv reset signature

* Change subprocenv seed cmd to call reset instead

* Fix type check

* Add backward compat

* Add `compat_gym_seed` helper

* Add goal env checks in env_checker

* Add docs on  HER requirements for envs

* Capture user warning in test with inverted box space

* Update ale-py version

* Fix randint

* Allow noop_max to be zero

* Update changelog

* Update docker image

* Update doc conda env and dockerfile

* Custom envs should not have any warnings

* Fix test for numpy >= 1.21

* Add check for vectorized compute reward

* Bump to gym 0.24

* Fix gym default step docstring

* Test downgrading gym

* Revert "Test downgrading gym"

This reverts commit 0072b77156c006ada8a1d6e26ce347ed85a83eeb.

* Fix protobuf error

* Fix in dependencies

* Fix protobuf dep

* Use newest version of cartpole

* Update gym

* Fix warning

* Loosen required scipy version

* Scipy no longer needed

* Try gym 0.25

* Silence warnings from gym

* Filter warnings during tests

* Update doc

* Update requirements

* Add gym 26 compat in vec env

* Fixes in envs and tests for gym 0.26+

* Enforce gym 0.26 api

* format

* Fix formatting

* Fix dependencies

* Fix syntax

* Cleanup doc and warnings

* Faster tests

* Higher budget for HER perf test (revert prev change)

* Fixes and update doc

* Fix doc build

* Fix breaking change

* Fixes for rendering

* Rename variables in monitor

* update render method for gym 0.26 API

backwards compatible (mode argument is allowed) while using the gym 0.26 API (render mode is determined at environment creation)

* update tests and docs to new gym render API

* undo removal of render modes metatadata check

* set rgb_array as default render mode for gym.make

* undo changes & raise warning if not 'rgb_array'

* Fix type check

* Remove recursion and fix type checking

* Remove hacks for protobuf and gym 0.24

* Fix type annotations

* reuse existing render_mode attribute

* return tiled images for 'human' render mode

* Allow to use opencv for human render, fix typos

* Add warning when using non-zero start with Discrete (fixes #1197)

* Fix type checking

* Bug fixes and handle more cases

* Throw proper warnings

* Update test

* Fix new metadata name

* Ignore numpy warnings

* Fixes in vec recorder

* Global ignore

* Filter local warning too

* Monkey patch not needed for gym 26

* Add doc of VecEnv vs Gym API

* Add render test

* Fix return type

* Update VecEnv vs Gym API doc

* Fix for custom render mode

* Fix return type

* Fix type checking

* check test env test_buffer

* skip render check

* check env test_dict_env

* test_env test_gae

* check envs in remaining tests

* Update tests

* Add warning for Discrete action space with non-zero (#1295)

* Fix atari annotation

* ignore get_action_meanings [attr-defined]

* Fix mypy issues

* Add patch for gym/gymnasium transition

* Switch to gymnasium

* Rely on signature instead of version

* More patches

* Type ignore because of https://github.com/Farama-Foundation/Gymnasium/pull/39

* Fix doc build

* Fix pytype errors

* Fix atari requirement

* Update env checker due to change in dtype for Discrete

* Fix type hint

* Convert spaces for saved models

* Ignore pytype

* Remove gitlab CI

* Disable pytype for convert space

* Fix undefined info

* Fix undefined info

* Upgrade shimmy

* Fix wrappers type annotation (need PR from Gymnasium)

* Fix gymnasium dependency

* Fix dependency declaration

* Cap pygame version for python 3.7

* Point to master branch (v0.28.0)

* Fix: use main not master branch

* Rename done to terminated

* Fix pygame dependency for python 3.7

* Rename gym to gymnasium

* Update Gymnasium

* Fix test

* Fix tests

* Forks don't have access to private variables

* Fix linter warnings

* Update read the doc env

* Fix env checker for GoalEnv

* Fix import

* Update env checker (more info) and fix dtype

* Use micromamab for Docker

* Update dependencies

* Clarify VecEnv doc

* Fix Gymnasium version

* Copy file only after mamba install

* [ci skip] Update docker doc

* Polish code

* Reformat

* Remove deprecated features

* Ignore warning

* Update doc

* Update examples and changelog

* Fix type annotation bundle (SAC, TD3, A2C, PPO, base class) (#1436)

* Fix SAC type hints, improve DQN ones

* Fix A2C and TD3 type hints

* Fix PPO type hints

* Fix on-policy type hints

* Fix base class type annotation, do not use defaults

* Update version

* Disable mypy for python 3.7

* Rename Gym26StepReturn

* Update continuous critic type annotation

* Fix pytype complain

---------

Co-authored-by: Carlos Luis <carlos.luisgonc@gmail.com>
Co-authored-by: Quentin Gallouédec <45557362+qgallouedec@users.noreply.github.com>
Co-authored-by: Thomas Lips <37955681+tlpss@users.noreply.github.com>
Co-authored-by: tlips <thomas.lips@ugent.be>
Co-authored-by: tlpss <thomas17.lips@gmail.com>
Co-authored-by: Quentin GALLOUÉDEC <gallouedec.quentin@gmail.com>
2023-04-14 13:13:59 +02:00
WeberSamuel
15c9daa2ba
Fix VecExtractDictObs does not handle terminal observation (#1443)
* VecExtractDictObs handle terminal_observation

* Added VecExtractDictObs handle terminal_output to changelog

* Update changelog.rst

* Update test_vec_extract_dict_obs.py

Add random dones in env to test if terminal_observation is properly handled

* Made test deterministic

* Fixed bug in test

* Improved test

* Fix format in test

* Update test

* Fix type hint

* Ignore pytype warning

* Ignore pytype

---------

Co-authored-by: Antonin RAFFIN <antonin.raffin@ensta.org>
2023-04-12 15:20:04 +02:00
npit
4232f9daa9
Rename the observations variable in the evaluation util to avoid shadowing (#1288)
* Rename the observations variable in the evaluation util to avoid shadowing

This enables a callback in evaluate_policy to have access to the
observation vector that is fed to the environment step function,
which is currently shadowed by the output observation.

* Update changelog

* Add test

* Move assignment outside of the loop

---------

Co-authored-by: Antonin RAFFIN <antonin.raffin@ensta.org>
Co-authored-by: Antonin Raffin <antonin.raffin@dlr.de>
2023-04-11 18:00:33 +02:00
Antonin RAFFIN
84f5511e08
Update changelog and cleanup (#1434) 2023-04-08 15:36:55 +02:00
Jonas Reiher
12250eb761
Add stats window argument (#1424)
* added stats_window_size argument

* updated changelog

* docstring info updated

* added missing tensorboard log docstring

* added stats_window_size argument for all models

* fixed stats_window_size test

* Update version

---------

Co-authored-by: Antonin Raffin <antonin.raffin@dlr.de>
2023-04-05 11:33:26 +02:00
Antonin RAFFIN
5a70af8abd
Fix type hints for DQN (#1354)
* Fix type hints for DQN

* [ci skip] Remove commented line

* Refine types

* Fix vectorized obs detection

* Fix for pytype

* Fix check at load time to create replay buffer

* One config file to rule them all

* Delete unused config

---------

Co-authored-by: Quentin Gallouédec <45557362+qgallouedec@users.noreply.github.com>
2023-03-30 11:31:47 +02:00
Omar Younis
a60b0179e0
Fix: Reshape action in DictRolloutBuffer (#1395)
* reshape action in DictRolloutBuffer

* improve buffer test

* update changelog

* add comment

* Update comments and version

---------

Co-authored-by: Antonin Raffin <antonin.raffin@dlr.de>
2023-03-29 16:25:05 +02:00
Fiete
b6aa507a22
Make check_env assertions in regards to observation_space more actionable (#1400)
* add instructions for running single tests in the README, add assertions for observation_space

* update changelog

* address linting warnings

* correct pytest command in the README

* correct review comments, run make commit-checks

* truncate lines that are too long

* address make lint warning about checking module availability

* fix tests

* use f-strings for formatting assertion messages

* fix type issue

* Refactor tests, improve error messages

---------

Co-authored-by: Antonin Raffin <antonin.raffin@dlr.de>
2023-03-29 15:26:03 +02:00
Quentin Gallouédec
c5adad82b2
Multiprocessing support for HerReplayBuffer (#704)
* IM compat. modif from old fork

* mp her working, without offline sampling

* update readme and doc

* fix discrete action/obs space case

* handle offline sampling

* fix pos to be consistent with the old version

* improve typing and docstring

* fix discrete obs special case

* new her, using episode uid

* deal with full buffer

* offline not implemented

* info storage; compute_reward as arg; offline sampling error

* offline sampling; timeout_termination; fix last_trans detection

* rm max_episode_length from tests

* fix loading and loading test

* Fix episode sampling strategy

* Episode interrupted not valid

* Typo

* Fix infos sampling, next_obs desired goals, offline sampling

* update tests for multienvs

* speed up code

* handle timeout sampling when samping

* give up ep_uid for ep_start and ep_lenght

* speed up sampling

* Improve docstring

* Typos and renaming

* Fix typing

* Fix linter warnings

* Renaming + add note

* fix reward type

* Fix future sampling strategy

* Fix future goal selection strategy

* env_fn as lambda

* Re-fix linter warnings

* Formatting

* Fix offline sampling

* restore the initial performance budget

* Remove max_episode_length for HerReplayBuffer kwargs

* SubprcVecEnv compat test

* Dedicated SubrocVecEnv test rm n_envs from parametrization

* Back to using the env arg instead of compute_reward

* Up VecEnv import

* fix lint warnings

* fix docstring

* Fix device issue

* actor_loss_modifier in SAV and TD3

* Merge RewardModifier and ActorLossModifier into Surgeon

* update surgeon for rnd

* fix uninteded merge

* fix uninteded merge

* fix unintended merge

* Rm unintended merge

* Fix KeyError

* Remove useless `all_inds`

* Minor docstring format

* Fix hint

* speedup!

* Speedup again

* speedup

* np.nonzero

* fix env normalization

* flat sampling for speedup

* typo

* drop online

* format

* remove observation from env_cheker (see #1335)

* update changelog

* default device to "auto"

* add comment for info storage

* add comment for ep_start and ep_length attributes

* a[b][c] to a[b, c]

* comment flatnonzero and unravel_index

* update _sample_goals docstring

* Fix future gaol sampling for split episode

* add informative error message for learning_starts too small

* use keyword arg for env

* try fix pytye

* Update stable_baselines3/common/off_policy_algorithm.py

Co-authored-by: Antonin RAFFIN <antonin.raffin@ensta.org>

* Add `copy_info_dict` option

* Ignore pytype

* Update changelog

* Rename variables and improve documentation

* Ignore new bug bear rule

* Add note about future strategy

* Add deprecation warning

* Fix bug trying to pickle buffer kwargs

---------

Co-authored-by: Antonin RAFFIN <antonin.raffin@ensta.org>
2023-03-20 12:03:57 +01:00
Antonin RAFFIN
e5deeed16e
Update doc about Gymnasium support (#1382) 2023-03-14 12:43:19 +01:00
Antonin RAFFIN
470771b5c2
Fix Atari Roms download, enable RUF linting (#1379)
* Add extra no Atari and fix CI for forks

* Enable ruff rules

* Change to no roms
2023-03-12 18:47:52 +01:00
Antonin RAFFIN
10e83865ec
Switch to pyproject.toml and ruff (#1361)
* Switch to `pyproject.toml` and `ruff`

* Fix for Atari ROMs and mypy

* Switch order in CI, lint first
2023-03-11 22:15:26 +01:00
Antonin RAFFIN
f0382a25bd
Add documentation about default network architecture (#1353)
* Add documentation about default network architecture

* [ci skip] Rename custom policy section to Policy Networks
2023-03-02 14:14:57 +01:00
Antonin RAFFIN
ed8783cb73
Add support for dict/tuple obs space for VecCheckNaN (#1348)
* Add support for dict/tuple obs space for VecCheckNaN

* Handle list too

* Address comments from code review

* Ignore B028 (explicit stack level)
2023-02-27 13:45:17 +01:00
Antonin RAFFIN
085bdd5a68
Remove deprecated usage of feature extractor (#1296)
* Remove deprecated usage of feature extractor

* Update changelog and version

* Update changelog.rst
2023-02-19 12:53:10 +01:00
Quentin Gallouédec
12e9917c24
Fix image-based normalized env loading (#1321)
* Fix

* Add test

* Update changelog

* fix memory error avoidance

* Update version

* image env test

* black

* check_shape_equal

* check shape equal in vecnormalize

* Allow spaces not to be box or dict

* rm `test_save_load_vecnormalized_image` in favor of `test_vec_env`

* Remove unused imports

---------

Co-authored-by: Antonin RAFFIN <antonin.raffin@ensta.org>
Co-authored-by: Antonin Raffin <antonin.raffin@dlr.de>
2023-02-15 14:17:18 +01:00
harveybellini
7a1e429702
Remove Note from examples - Code works (#1330)
* Remove Note

Gif creation works with Atari Environments using the script provided below.

* Update changelog

---------

Co-authored-by: Antonin Raffin <antonin.raffin@dlr.de>
2023-02-15 13:14:02 +01:00
Vikas Kumar
69b94dd6a8
Rename "timesteps" to "episodes" in log_interval documentation (#1325)
* change timestamp to episode for logging

* update changelog

* minor format modif

* minor format modif

---------

Co-authored-by: Quentin Gallouédec <45557362+qgallouedec@users.noreply.github.com>
2023-02-10 21:15:09 +01:00
Sidney Tio
489b1fdaf2
Add the argument dtype (default to float32) to the noise (#1301)
* Fixed noise to return float32

* Updated changelog

* Fixed test to use numpy arrays instead of python floats

* Sorted imports for tests

* Added dtype to constructor

* Removed dtype parameter for VectorizedActionNoise

* __init__ -> None; Capitalize and period in docstring when needed; fix dtype type hint; dtype in docstring

* fix dtype type hint

* Update version

* Clarify changelog [skip ci]

* empty commit to run ci

* Update docs/misc/changelog.rst

---------

Co-authored-by: Quentin Gallouédec <45557362+qgallouedec@users.noreply.github.com>
Co-authored-by: Antonin RAFFIN <antonin.raffin@ensta.org>
2023-02-07 13:42:14 +01:00
Quentin Gallouédec
2e4a45020e
Refactor observation stacking (#1238)
* refactor stacking obs

* Improve docstring

* remove all StackedDictObservations

* Update tests and make stacked obs clearer

* Fix type check

* fix stacked_observation_space

* undo init change, deprecate StackedDictObservations

* deprecate stack_observation_space

* type hints

* ignore pytype errors

* undo vecenv doc change

* Deprecation warning in StackedDictObs doctstring

* Fix vec_env.rst

* Fix __all__ sorting

* fix pytype ignore statement

* Update docstring

* stack

* Remove n_stack

* Update changelog

* Simplify code

* Rename test file

* Re-use variable for shift

* Fix doc build

* Remove pytype comment

* Disable pytype error

---------

Co-authored-by: Antonin RAFFIN <antonin.raffin@ensta.org>
2023-02-06 22:41:59 +01:00
adamfrly
411ff697dd
Ensure train/n_updates metric accounts for early stopping of training loop (#1311)
* Correct _n_updates when target_kl stops loop early

* Update changelog

* Simplify code

---------

Co-authored-by: Antonin Raffin <antonin.raffin@ensta.org>
2023-02-06 15:48:41 +01:00
Marco Tröster
d0c1a87faf
Add scaling section to A2C documentation (#1250)
* add scaling section to A2C documentation

* add cross-reference to vectorized envs article

* turn it as note

* update changelog

* add Bonifatius94 to the list of contributors

* fix issue number

---------

Co-authored-by: Quentin Gallouédec <45557362+qgallouedec@users.noreply.github.com>
Co-authored-by: Quentin GALLOUÉDEC <gallouedec.quentin@gmail.com>
Co-authored-by: Antonin RAFFIN <antonin.raffin@ensta.org>
2023-02-02 12:34:38 +01:00
Alex Pasquali
bea3c44ba5
Fixed typo in A2C's docstring (#1303) 2023-01-28 12:04:07 +01:00
Quentin Gallouédec
5ee9009535
Add sticky actions for Atari games (#1286)
* repeat_action_probability

* Add test

* Undo atari wrapper doc change since CI fails

* remove action_repeat_probability from make_atari_env

* Add sticky action wrapper and improve documentation

* Update changelog

* handle the case noop_max=0

* Update tests

* Comply to ALE implementation

* Reorder doc

* Add doc warning and don't wrap with sticky action when not needed

* fix docstring and reorder

* Move `action_repeat_probability` args at the last position

* Add ref

* Update doc and wrap with frameskip only if needed

* Update changelog

Co-authored-by: Antonin RAFFIN <antonin.raffin@ensta.org>
2023-01-26 10:32:58 +01:00
Quentin Gallouédec
637988c9cc
Fix Atari wrapper bug: tried to step environment that needs reset (#1297)
* fix 1060

* update changelog
2023-01-26 00:31:20 +01:00
Alex Pasquali
b702884c23
Removed shared layers in mlp_extractor (#1292)
* Modified actor-critic policies & MlpExtractor class

ActorCriticPolicy:
  - changed type hint of net_arch param: now it's a dict
  - removed check that if features extractor is not shared: no shared layers are allowed in the mlp_extractor regardless of the features extractor
ActorCriticCnnPolicy:
  - changed type hint of net_arch param: now it's a dict
MultiInputActorcriticPolicy:
  - changed type hint of net_arch param: now it's a dict
MlpExtractor:
  - changed type hint of net_arch param: now it's a dict
  - adapted networks creation
  - adapted methods: forward, forward_actor & forward_critic

* Removed shared layers in mlp_extractor

* Updated docs and changelog + reformat

* Updated custom policy tests

* Removed test on deprecation warning for share layers in mlp_extractor

Now shared layers are removed

* Update version

* Update RL Zoo doc

* Fix linter warnings

* Add ruff to Makefile (experimental)

* Add backward compat code and minor updates

* Update tests

* Add backward compatibility

* Fix test

* Improve compat code

Co-authored-by: Antonin RAFFIN <antonin.raffin@ensta.org>
2023-01-23 14:55:19 +01:00
Quentin Gallouédec
92f7a6f23b
Fix test_vec_normalize.py, test_tensorboard.py and common/monitor.py type hint (#1194)
* Remove from mypy exclude

* type hint for metadata

* Union[float, int] -> float

* Remove useless __init__

* Type hint for model and logger in BaseCallback

* Type hint for metric_dict

* Update changelog

* fix test_tensorboard

* ignore gamma type checking

* Fix monitor type hint

* Update logger type hints

* Fix type annotation and bump version

* Fix circular import

Co-authored-by: Antonin RAFFIN <antonin.raffin@ensta.org>
2023-01-13 18:28:22 +01:00
Yu Zheng
9bb1538b78
Fix outdated load_parameters to set_parameters (#1270)
* Update examples.rst

* Update changelog

Co-authored-by: Antonin Raffin <antonin.raffin@ensta.org>
2023-01-11 14:13:21 +01:00
Antonin RAFFIN
6b8905acdb
Release v1.7.0 (#1268) 2023-01-10 17:32:57 +01:00
Dominic Kerr
5aa6e7d340
Fix ProgressBarCallback under-reporting (#1260)
* Updated tqdm progress bar constructor to account for the effects of train_freq/n_steps/num_envs on total_timesteps. Ensure progress bar is "flushed" on training end.

* Added description of PR #1260. Fixed formatting typo

* Partial revert

Co-authored-by: dominicgkerr <dominicgkerr1@gmail.co>
Co-authored-by: Antonin RAFFIN <antonin.raffin@ensta.org>
Co-authored-by: Antonin Raffin <antonin.raffin@dlr.de>
2023-01-10 15:17:52 +01:00
Alex Pasquali
30a19848ce
Deprecation of shared layers in MlpExtractor (#1252)
* Deprecation warning for shared layers in Mlpextractor

* Updated changelog

* Updated custom policy doc

* Update doc and deprecation

* Fix doc build

* Minor edits

Co-authored-by: Antonin Raffin <antonin.raffin@ensta.org>
2023-01-05 09:59:36 +01:00
Quentin Gallouédec
4fa17dcf0f
Standardize the use of from gym import spaces (#1240)
* generalize the use of `from gym import spaces`

* command line get system info

* Documentation line length for doc

* update changelog

* add space before os plateform to avoid ref to other issue

* format

* get_system_info update in changelog

* fix type check error

* fix get system info

* add comment about regex

* update version
2023-01-02 14:51:11 +01:00
Friedrich Yuan
2bb8ef5e63
Add RLeXplore to the project page (#1246)
* Update project page

Adding the repo "rl-exploration-baselines" to the project page.

* Update changelog.rst

* Update projects.rst

* Update changelog.rst

* Update docs/misc/projects.rst

* Update changelog.rst

Co-authored-by: Quentin Gallouédec <45557362+qgallouedec@users.noreply.github.com>
2022-12-28 15:06:09 +01:00
Antonin RAFFIN
e78ba6ffa4
Hotfix to load policies saved with SB3 <= v1.6 (#1234)
* Hotfix to load policies saved with SB3 <= v1.6

* Add warning and test

* Update doc
2022-12-22 23:58:30 +01:00
Antonin RAFFIN
3c028f3d5c
Fix load_from_tensor (#1231) 2022-12-22 17:28:18 +01:00
Quentin Gallouédec
5549b34231
Fix `stable_baselines3/common/vec_env/vec_check_nan.py` type hints (#1226)
* super() init style

* "async_step" arg to "event"; "news" to "dones"; improve docstring

* Remove vec_check_nan from mypy exclude

* Update changelog
2022-12-22 12:24:59 +01:00
Quentin Gallouédec
9aff1137a9
Add support for Python 3.10 (#1227)
* Add python 3.10 and 3.11

* Update setup

* Fix CI

* Drop 3.11 (because of pytorch)

* Update changelog

* revert unwanted change in setup.cfg

* Remove remark about pytorch
2022-12-21 15:52:48 +01:00
Antonin RAFFIN
7202ece85b
Update tensorboard callback doc (#1221)
Co-authored-by: Quentin Gallouédec <45557362+qgallouedec@users.noreply.github.com>
2022-12-21 12:51:28 +01:00
Quentin Gallouédec
7fb8336f40
Update PR template (#1225)
Co-authored-by: Antonin RAFFIN <antonin.raffin@ensta.org>
2022-12-20 15:13:42 +01:00
Alex Pasquali
2cfcec4f50
Modified ActorCriticPolicy to support non-shared features extractor (#1148)
* Modified ActorCriticPolicy to support non-shared features extractor

* Refactored features extraction with non-shared features extractor in ActorCriticPolicy and updated doc

Doc update: added 'warning' on custom policy docs that says that, if the features extractor is non-shared, it's not possible to have shared layers in the mlp_extractor

* Moved attrib share_features_extractor in class

* Updated custom policy doc for non-shared features extractor

* Updated changelog

* Made some if-statements more readable if policies.py

The if-statements are related to the shared/non-shared features extractor in ActorCritic policies

* Simplify implementation and add run test

* Keep order in module gain to keep previous results consistents

* Fix test

* Improved docstring in policies.py

Co-authored-by: Quentin Gallouédec <45557362+qgallouedec@users.noreply.github.com>

* Added some tests

* feature extractor -> features extractor

* Fix test

* Fix env_id in test

* Make features extractor parameter explicit

* Remove duplicate

Co-authored-by: Antonin RAFFIN <antonin.raffin@ensta.org>
Co-authored-by: Quentin Gallouédec <45557362+qgallouedec@users.noreply.github.com>
Co-authored-by: Antonin Raffin <antonin.raffin@dlr.de>
2022-12-20 15:12:05 +01:00
Antonin RAFFIN
8452106734
Fix support of image like normalized inputs (#1214)
* Fix support of image like normalized inputs

* Improve docstring and warning message.

* Don't check if obs is image when normalize_images is False (lil opt)

* Comment fix

* Fix normalize_images not passed to parent

* Check for subclasses too

* Remove useless multiline

* Update version and add comment

* Fix some typos

Co-authored-by: Quentin Gallouédec <45557362+qgallouedec@users.noreply.github.com>
2022-12-20 13:18:28 +01:00
Quentin Gallouédec
ca944fed2d
Update version (#1220)
* Replace .to(device) when possible

* fix numpy dep

* black

* Add warning for device != cpu and copy=False

* Update changelog

* Remove warning

* Update buffers.py

* Update version

* Fix type checking

Co-authored-by: Antonin RAFFIN <antonin.raffin@ensta.org>
2022-12-19 13:53:00 +01:00
Antonin Raffin
9af2d11b6e
Update changelog 2022-12-19 13:21:10 +01:00
Quentin Gallouédec
68a40e0940
Construct tensors directly on GPU (#1218)
* Replace .to(device) when possible

* fix numpy dep

* black

* Add warning for device != cpu and copy=False

* Update changelog

* Remove warning

* Update buffers.py
2022-12-19 12:50:22 +01:00
Antonin RAFFIN
0c1bc0b1da
Fix stable_baselines3/common/atari_wrappers.py type hints (#1216)
* Fix `stable_baselines3/common/atari_wrappers.py` type hints

* Fix initialization

Co-authored-by: Quentin Gallouédec <45557362+qgallouedec@users.noreply.github.com>
2022-12-18 16:13:44 +01:00