Use dim= instead of axis= in comfort_reward._within_bound#99
Open
lonexreb wants to merge 1 commit intoNVlabs:mainfrom
Open
Use dim= instead of axis= in comfort_reward._within_bound#99lonexreb wants to merge 1 commit intoNVlabs:mainfrom
lonexreb wants to merge 1 commit intoNVlabs:mainfrom
Conversation
`_within_bound` calls ``torch.all(metric_within_bound, axis=-1)`` -- the NumPy keyword. PyTorch accepts ``axis=`` as a deprecated alias for ``dim=``, so the call still works, but it is the only ``axis=`` usage in the entire file: every other reduction in comfort_reward.py uses the PyTorch-idiomatic ``dim=`` (lines 47, 49, 54, 91, 128, 131). Switch to ``dim=-1`` so the file reads consistently. The semantics are identical (`torch.all(x, axis=-1) == torch.all(x, dim=-1)`). Verified after the change: ``grep -n "axis=" finetune/rl/rewards/comfort_reward.py`` returns nothing. Signed-off-by: lonexreb <[email protected]>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
_within_boundinfinetune/rl/rewards/comfort_reward.pyis the only spot in the file that uses NumPy-styleaxis=rather than PyTorch'sdim=:Every other reduction in the same file uses the PyTorch-idiomatic
dim=:delta = tensor[..., 1:] - tensor[..., :-1](slicing, fine)torch.diff(yaw, dim=-1)torch.linalg.norm(..., dim=-1)_within_bound(...).mean(2)(positional dim)comfort_metric_dict[name].mean(dim=-1)PyTorch accepts
axis=as a deprecated alias fordim=, so the call still works — this is purely a consistency fix.Fix
One-character change:
axis=-1→dim=-1. Semantics are identical (torch.all(x, axis=-1) == torch.all(x, dim=-1)).Verification
After the change:
grep -n "axis=" finetune/rl/rewards/comfort_reward.pyreturns nothing.