Skip to content

Commit

Permalink
[Refactor] Import enum and interaction_type utils (pytorch#1055)
Browse files Browse the repository at this point in the history
  • Loading branch information
Goldspear authored Apr 13, 2023
1 parent 40004e6 commit d9bdac9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -440,9 +440,9 @@ And it is `functorch` and `torch.compile` compatible!

```python
policy_explore = EGreedyWrapper(policy)
with set_exploration_mode("random"):
with set_exploration_type(ExplorationType.RANDOM):
tensordict = policy_explore(tensordict) # will use eps-greedy
with set_exploration_mode("mode"):
with set_exploration_type(ExplorationType.MODE):
tensordict = policy_explore(tensordict) # will not use eps-greedy
```
</details>
Expand Down
6 changes: 4 additions & 2 deletions docs/source/reference/envs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -372,8 +372,10 @@ Helpers

step_mdp
get_available_libraries
set_exploration_mode
exploration_mode
set_exploration_mode #deprecated
set_exploration_type
exploration_mode #deprecated
exploration_type
check_env_specs
make_composite_from_td

Expand Down
6 changes: 6 additions & 0 deletions torchrl/envs/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,14 @@
import pkg_resources
import torch
from tensordict.nn.probabilistic import ( # noqa
# Note: the `set_/interaction_mode` and their associated arg `default_interaction_mode` are being deprecated!
# Please use the `set_/interaction_type` ones above with the InteractionType enum instead.
# See more details: https://github.com/pytorch/rl/issues/1016
interaction_mode as exploration_mode,
interaction_type as exploration_type,
InteractionType as ExplorationType,
set_interaction_mode as set_exploration_mode,
set_interaction_type as set_exploration_type,
)
from tensordict.tensordict import TensorDictBase

Expand Down

0 comments on commit d9bdac9

Please sign in to comment.