Problem
TemporalOrderDataset can select the same frame for both the pre- and post-window in both label classes.
Positive sampling includes frame_idx_pre:
frame_idx_post = torch.randint(
frame_idx_pre,
self.window_selector.lengths[rec_idx_pre],
...
)
Strict-negative sampling also includes frame_idx_pre:
frame_idx_post = torch.randint(
0,
frame_idx_pre + 1,
...
)
Therefore, when frame_idx_post == frame_idx_pre, x_pre and x_post are identical. Their concatenation produces the same model input regardless
of whether the label is positive or negative.
This is guaranteed at certain boundaries:
- A strict-negative sample whose pre-frame is the first frame.
- A positive sample whose pre-frame is the final frame.
It can also occur randomly elsewhere in a recording.
This appears to be a residual ambiguity following #55 and #56 rather than the original positive-sampling bug addressed there.
Expected behavior
For the strict method, temporal relationships should be unambiguous:
- Positive: frame_idx_post > frame_idx_pre
- Negative: frame_idx_post < frame_idx_pre
The same pre/post pair should never receive both labels.
Suggested resolution
Exclude zero-distance pairs and handle sequence boundaries explicitly. Possible approaches include:
- Resample the pre-frame when the requested class is impossible at that boundary.
- Sample the pre-frame from a class-specific valid range.
- Resample the class while preserving the intended class balance.
The implementation should avoid introducing class imbalance or an unbounded retry loop for very short records.
Tests
Use the existing pre_coords and post_coords debugging attributes to verify that:
- Positive samples always satisfy post > pre.
- Strict-negative samples always satisfy post < pre.
- Zero-distance pairs are never produced.
- First-frame and final-frame boundary cases terminate correctly.
- Seeded sampling remains deterministic.
Problem
TemporalOrderDatasetcan select the same frame for both the pre- and post-window in both label classes.Positive sampling includes
frame_idx_pre:Strict-negative sampling also includes frame_idx_pre:
Therefore, when frame_idx_post == frame_idx_pre, x_pre and x_post are identical. Their concatenation produces the same model input regardless
of whether the label is positive or negative.
This is guaranteed at certain boundaries:
It can also occur randomly elsewhere in a recording.
This appears to be a residual ambiguity following #55 and #56 rather than the original positive-sampling bug addressed there.
Expected behavior
For the strict method, temporal relationships should be unambiguous:
The same pre/post pair should never receive both labels.
Suggested resolution
Exclude zero-distance pairs and handle sequence boundaries explicitly. Possible approaches include:
The implementation should avoid introducing class imbalance or an unbounded retry loop for very short records.
Tests
Use the existing pre_coords and post_coords debugging attributes to verify that: