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

[BugFix] Support for tensor collection in the PPOLoss #2543

Merged
merged 3 commits into from
Nov 6, 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
Use the build in function
  • Loading branch information
Pau Riba committed Nov 6, 2024
commit ef794c7d00fc73de8bbd79e55057e14799941ee7
2 changes: 1 addition & 1 deletion torchrl/objectives/ppo.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ def reset(self) -> None:
def get_entropy_bonus(self, dist: d.Distribution) -> torch.Tensor:
try:
entropy = dist.entropy()
if isinstance(entropy, TensorDict) and hasattr(dist, "entropy_key"):
if is_tensor_collection(entropy) and hasattr(dist, "entropy_key"):
entropy = entropy.get(dist.entropy_key).unsqueeze(-1)
except NotImplementedError:
x = dist.rsample((self.samples_mc_entropy,))
Expand Down