BatchedTrajectory¶
- class standard_e2e.data_structures.BatchedTrajectory(trajectories, device=None, side='right', strict=False)[source]¶
Bases:
objectData container for a batch of trajectories.
__init__ accepts a NON-EMPTY list of Trajectory objects.
Empty trajectories inside the list are allowed and zero-filled.
strict=True: all non-empty trajectories must have the same component set (IS_VALID always included). strict=False: union of components; per-sample missing components are zero-filled.
Stores per-component tensors float32 (batch_size, sequence_length) on one device.
- Exposes:
get(…, strict=…) -> (batch_size, sequence_length, num_components)
scores: (batch_size,) float32 (NaN where missing)
is_empty_mask: (batch_size,) bool
.to(device) / .cuda()
- Parameters:
trajectories (Sequence[Trajectory])
device (device | None)
side (str)
strict (bool)
- get(components, *, strict=True)[source]¶
Retrieve stacked component tensors of shape
(B, T, K).- Parameters:
components (
Union[TrajectoryComponent,Sequence[TrajectoryComponent]]) – Single component or sequence thereof.strict (
bool) – If True, missing components raiseKeyError; otherwise zeros are returned for missing entries.
- Return type:
- has(component)[source]¶
Check if a trajectory component is present.
- Return type:
- Parameters:
component (TrajectoryComponent)
- property is_empty_mask: Tensor¶
Return a mask indicating which trajectories in the batch are empty.
- pad(target_length, *, side='right')[source]¶
Pad all sequences in the batch to
target_lengthwith zeros.- Return type:
- Parameters:
- pad_or_trim(target_length, *, side='right')[source]¶
Pad or trim batch to
target_lengthdepending on current length.- Return type:
- Parameters:
- resample(time_lattice)[source]¶
Return a new BatchedTrajectory resampled onto a new time lattice.
This constructs (optionally cloned) copies of the original per-sample Trajectory objects, calls their
Trajectory.resamplemethod, and returns a freshly built BatchedTrajectory. The current object is not modified.