Skip to content
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

[Feature] Extend TensorDictPrimer default_value options #2071

Merged
merged 21 commits into from
Apr 18, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feedback changes
  • Loading branch information
albertbou92 committed Apr 16, 2024
commit 311f40b026e14e4a47e2413fbcc0162ed3d9f65a
8 changes: 2 additions & 6 deletions torchrl/envs/transforms/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -4521,15 +4521,11 @@ def __init__(
) # if not random and no default value, use 0.0
self.random = random
if isinstance(default_value, dict):
primer_keys = self.primers.keys(True, True)
default_value_keys = {unravel_key(key) for key in default_value.keys()}
if primer_keys != default_value_keys:
default_value = TensorDict(default_value, []).to_dict()
if set(default_value.keys()) != set(self.primers.keys(True, True)):
raise ValueError(
"If a default_value dictionary is provided, it must match the primers keys."
)
default_value = {
key: default_value[key] for key in self.primers.keys(True, True)
}
else:
default_value = {
key: default_value for key in self.primers.keys(True, True)
Expand Down