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

polish(mark): add hybrid action space support to ActionNoiseWrapper #829

Merged
merged 3 commits into from
Sep 20, 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
7 changes: 5 additions & 2 deletions ding/model/wrapper/model_wrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -866,10 +866,13 @@ def forward(self, *args, **kwargs):
assert isinstance(output, dict), "model output must be dict, but find {}".format(type(output))
if 'action' in output or 'action_args' in output:
key = 'action' if 'action' in output else 'action_args'
action = output[key]
action = output[key]['action_args'] if isinstance(output[key], dict) else output[key]
puyuan1996 marked this conversation as resolved.
Show resolved Hide resolved
assert isinstance(action, torch.Tensor)
action = self.add_noise(action)
output[key] = action
if isinstance(output[key], dict):
output[key]['action_args'] = action
else:
output[key] = action
return output

def add_noise(self, action: torch.Tensor) -> torch.Tensor:
Expand Down
Loading