Fix padding shape in split_and_pad_trajectories to support arbitrary additional dimensions #77
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.
Description
This PR fixes an issue in
split_and_pad_trajectories(tensor, dones)
where creating a full-length trajectory incorrectly assumes the input tensor is 3D ([time, number of envs, feature_dim]
). This assumption fails for higher-dimensional tensors, such as images ([time, number of envs, channel, width, height]
), where there are multiple additional dimensions. The previous approach, which used only the last dimension (shape[-1]
), caused shape mismatches when adding a full-length zero trajectory.Key Changes
Instead of assuming a single feature dimension (
shape[-1]
), the full-length trajectory is now created using all feature dimensions beyond the second dimension (number of environments
), represented by*shape[2:]
.This ensures compatibility with tensors of arbitrary additional dimensions while preserving the intended functionality.
For reference, the following line is changed:
rsl_rl/rsl_rl/utils/utils.py
Line 66 in f80d475