forked from AlignmentResearch/stable-baselines3
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from AlignmentResearch/start-from-numpy
Port in torchified PPO from sb3_contrib
- Loading branch information
Showing
16 changed files
with
287 additions
and
178 deletions.
There are no files selected for viewing
This file contains 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 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 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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from typing import Callable, TypeVar | ||
|
||
import optree as ot | ||
from optree import PyTree as PyTree | ||
|
||
__all__ = ["tree_flatten", "PyTree"] | ||
|
||
T = TypeVar("T") | ||
|
||
SB3_NAMESPACE = "stable-baselines3" | ||
|
||
|
||
def tree_flatten( | ||
tree: ot.PyTree[T], | ||
is_leaf: Callable[[T], bool] | None = None, | ||
*, | ||
none_is_leaf: bool = False, | ||
namespace: str = SB3_NAMESPACE | ||
) -> tuple[list[T], ot.PyTreeSpec]: | ||
"""optree.tree_flatten(...) but the default namespace is SB3_NAMESPACE""" | ||
return ot.tree_flatten(tree, is_leaf, none_is_leaf=none_is_leaf, namespace=namespace) |
This file contains 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
Oops, something went wrong.