Skip to content

Commit

Permalink
Raise ValueError if horizon is incompatible with downsampling (#422)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-soare authored Sep 9, 2024
1 parent 9c46366 commit a60d27b
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lerobot/common/policies/diffusion/configuration_diffusion.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,3 +196,12 @@ def __post_init__(self):
f"`noise_scheduler_type` must be one of {supported_noise_schedulers}. "
f"Got {self.noise_scheduler_type}."
)

# Check that the horizon size and U-Net downsampling is compatible.
# U-Net downsamples by 2 with each stage.
downsampling_factor = 2 ** len(self.down_dims)
if self.horizon % downsampling_factor != 0:
raise ValueError(
"The horizon should be an integer multiple of the downsampling factor (which is determined "
f"by `len(down_dims)`). Got {self.horizon=} and {self.down_dims=}"
)

0 comments on commit a60d27b

Please sign in to comment.