-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Add Trainers as generators #559
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Trinkle23897
merged 46 commits into
thu-ml:master
from
jamartinh:trainers_as_generators
Mar 17, 2022
Merged
Changes from all commits
Commits
Show all changes
46 commits
Select commit
Hold shift + click to select a range
8bad065
add docstring :param buffer to offline_trainer in offline.py
jamartinh ff9c0c9
Add param yield_epoch to trainers. if True, converts the function int…
jamartinh 2b72992
Add trainer geneators for offline.py, offpolicy.py and onpolicy.py .
jamartinh 9a6a72b
fix PEP8
jamartinh d05f0e0
fix PEP8
jamartinh 5566be0
fix PEP8
jamartinh 185c006
fix yapf
jamartinh 79f050a
removed comments in format section of Makefile. It produces errors on…
jamartinh 4cbc7c8
fix isort
jamartinh ffbe30a
fix rare error with dict with mypy
jamartinh 23f00d2
fix rare error with dict with mypy
jamartinh f64eb2d
fix docstrings
jamartinh b6b0ed7
refactored offline.py to one iterator class
jamartinh 0f39eac
drop test_sac_with_il_trainer_generator.py
jamartinh 21cdbe6
improve offline.py with best practices on exhausting iterator and cle…
jamartinh 2483dea
Create an Iterator class instead of a generator function, following t…
jamartinh 88cb63c
Expose new _iter versions and Iterator Classes
jamartinh 34feb5b
Add OffPolicyTrainer as Iterator adn add testing in test_td3.py
jamartinh 1c7eaef
fix doc format
jamartinh 4067428
Merge branch 'master' into trainers_as_generators
Trinkle23897 5ca6fb8
* Refactored trainers into One BaseTrainer class.
jamartinh d705744
Merge remote-tracking branch 'jamh/trainers_as_generators' into train…
jamartinh b4fa395
fix formatting
jamartinh 91c787c
Merge remote-tracking branch 'origin/master' into trainers_as_generators
Trinkle23897 c1f5f25
docs
Trinkle23897 b12beb1
fix missing import
Trinkle23897 a4ae2e3
* fix formatting
jamartinh 0690d12
Merge branch 'thu-ml:master' into trainers_as_generators
jamartinh e2756f0
Merge branch 'master' into trainers_as_generators
Trinkle23897 c902d61
update docs
Trinkle23897 a3e7e2c
update rst
Trinkle23897 651726f
fix early stopping during train [train_step]
jamartinh e6b00e2
* fix early stopping during train train_step
jamartinh 4d76843
* fix early stopping during train train_step
jamartinh 23ce483
* fix early stopping during train train_step
jamartinh 1d707f8
* fix early stopping during train train_step
jamartinh 479b794
* fix early stopping during train train_step
jamartinh 3adf0e1
Merge branch 'master' into trainers_as_generators
Trinkle23897 08f65a6
fix a bug in BaseTrainer.run return value missing
Trinkle23897 5ec4eb3
change seed to pass ci
Trinkle23897 89ce44f
learning_type: str
Trinkle23897 a320e68
fix ci
Trinkle23897 6df9365
reorg some code
Trinkle23897 7a00daf
revert
Trinkle23897 3ce4f6d
missing docs for on-policy trainer
Trinkle23897 a62cf84
missing docs
Trinkle23897 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,49 @@ | ||
tianshou.trainer | ||
================ | ||
|
||
.. automodule:: tianshou.trainer | ||
|
||
On-policy | ||
--------- | ||
|
||
.. autoclass:: tianshou.trainer.OnpolicyTrainer | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
.. autofunction:: tianshou.trainer.onpolicy_trainer | ||
|
||
.. autoclass:: tianshou.trainer.onpolicy_trainer_iter | ||
|
||
|
||
Off-policy | ||
---------- | ||
|
||
.. autoclass:: tianshou.trainer.OffpolicyTrainer | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
.. autofunction:: tianshou.trainer.offpolicy_trainer | ||
|
||
.. autoclass:: tianshou.trainer.offpolicy_trainer_iter | ||
|
||
|
||
Offline | ||
------- | ||
|
||
.. autoclass:: tianshou.trainer.OfflineTrainer | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
.. autofunction:: tianshou.trainer.offline_trainer | ||
|
||
.. autoclass:: tianshou.trainer.offline_trainer_iter | ||
|
||
|
||
utils | ||
----- | ||
|
||
.. autofunction:: tianshou.trainer.test_episode | ||
|
||
.. autofunction:: tianshou.trainer.gather_info |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,34 @@ | ||
"""Trainer package.""" | ||
|
||
# isort:skip_file | ||
|
||
from tianshou.trainer.utils import test_episode, gather_info | ||
from tianshou.trainer.onpolicy import onpolicy_trainer | ||
from tianshou.trainer.offpolicy import offpolicy_trainer | ||
from tianshou.trainer.offline import offline_trainer | ||
from tianshou.trainer.base import BaseTrainer | ||
from tianshou.trainer.offline import ( | ||
OfflineTrainer, | ||
offline_trainer, | ||
offline_trainer_iter, | ||
) | ||
from tianshou.trainer.offpolicy import ( | ||
OffpolicyTrainer, | ||
offpolicy_trainer, | ||
offpolicy_trainer_iter, | ||
) | ||
from tianshou.trainer.onpolicy import ( | ||
OnpolicyTrainer, | ||
onpolicy_trainer, | ||
onpolicy_trainer_iter, | ||
) | ||
from tianshou.trainer.utils import gather_info, test_episode | ||
|
||
__all__ = [ | ||
"BaseTrainer", | ||
"offpolicy_trainer", | ||
"offpolicy_trainer_iter", | ||
"OffpolicyTrainer", | ||
"onpolicy_trainer", | ||
"onpolicy_trainer_iter", | ||
"OnpolicyTrainer", | ||
"offline_trainer", | ||
"offline_trainer_iter", | ||
"OfflineTrainer", | ||
"test_episode", | ||
"gather_info", | ||
] |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.