Skip to content

Conversation

Cadene
Copy link
Collaborator

@Cadene Cadene commented Apr 20, 2024

What does this PR do?

  • Remove stats.pth
  • Add optional dataset_stats argument to policies
    • For the first training, expected to be dataset_stats=dataset.stats
    • For loading checkpoint for finetuning or evaluation, expected to be dataset_stats=None since the stats are inside policy.state_dict()
  • Remove transform
    • Remove from datasets/factory.py
    • Remove from envs/utils.py
    • Delete transforms.py
  • Add input_shapes, output_shapes, normalize_input_modes, unnormalize_output_modes in config yaml and configuration_POLICY.py
    • They are used to create the stats buffer inside the policy used during normalization and unnormalization.
    • input_shapes and output_shapes can also be used to instantiate the nn.Module of the policy, but I left this for future PR
  • Add policies/normalize.py containing Normalize and Unnormalize, which are nn.Module of the policy
  • Add test_policies.py::test_normalize

How was it tested?

CI + breakpoint

@Cadene Cadene self-assigned this Apr 20, 2024
Comment on lines 72 to 79
# Normalization / Unnormalization
normalize_input_modes: dict[str, str] = {
"observation.image": "mean_std",
"observation.state": "min_max",
}
unnormalize_output_modes: dict[str, str] = {
"action": "min_max",
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Contributor

@alexander-soare alexander-soare left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Cadene nice! This makes things a lot cleaner. I'm in agreement with your approach and have left some minor passing comments. Looking forward to reviewing the final PR.

@Cadene Cadene changed the title Move normalize/unnormalize transforms to policy for act and diffusion Move stats to policy for act and diffusion Apr 22, 2024
Base automatically changed from user/rcadene/2024_04_18_episode_data_index to main April 23, 2024 12:13
@Cadene Cadene force-pushed the user/rcadene/2024_04_20_move_normalize_unnormalize_policy branch from cf45d92 to 42ed7bb Compare April 23, 2024 17:56
@aliberts aliberts added policies Items related to robot policies dataset Issues regarding data inputs, processing, or datasets labels Apr 24, 2024
@Cadene Cadene marked this pull request as ready for review April 24, 2024 15:40
@Cadene Cadene changed the title Move stats to policy for act and diffusion Move normalization to policy for act and diffusion Apr 24, 2024
Copy link
Contributor

@alexander-soare alexander-soare left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for this PR Remi. Super clean design. I left some comments, and I think for some it might make sense for me to contribute to the PR a bit.

"""

# Environment.
# TODO(rcadene, alexander-soar): remove these as they are defined in input_shapes, output_shapes
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note to self so I don't forget. I will contribute to this PR to do this now

Copy link
Contributor

@alexander-soare alexander-soare left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved after you merge my PR

@Cadene Cadene merged commit e760e4c into main Apr 25, 2024
@Cadene Cadene deleted the user/rcadene/2024_04_20_move_normalize_unnormalize_policy branch April 25, 2024 09:47
menhguin pushed a commit to menhguin/lerobot that referenced this pull request Feb 9, 2025
Kalcy-U referenced this pull request in Kalcy-U/lerobot May 13, 2025
ZoreAnuj pushed a commit to luckyrobots/lerobot that referenced this pull request Jul 29, 2025
Ricci084 pushed a commit to JeffWang987/lerobot that referenced this pull request Sep 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dataset Issues regarding data inputs, processing, or datasets policies Items related to robot policies
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants