Multi-Hypothesis Trajectory Prediction
Detection, Video & Advanced Vision DS practice problem on Onlearn.
Difficulty: medium.
Topics: Multi-Hypothesis Trajectory Prediction, Mixture Density Networks, Kalman Filtering, Transformer Decoders, Variational Inference, Negative Log-Likelihood Loss, Computer Vision, Probabilistic Graphical Models, Deep Learning, Control Theory, Optimization Theory, Sequence Modeling, Generative Modeling, Motion Analysis, Uncertainty Quantification, Attention Mechanisms.
In many motion forecasting scenarios (autonomous driving, robotics, pedestrian tracking), predicting a single future trajectory is often insufficient because the future is inherently uncertain. Instead, models predict multiple possible future trajectories (called hypotheses), each with an associated probability. Implement a function that evaluates a set of K predicted trajectory hypotheses against a single ground truth trajectory. Each trajectory is a sequence of T 2D points representing positions over time. Given: predictions: A list of K trajectories, where each trajectory is a list of T [x, y] coordinate pairs probabilities: A list of K probability values (summing to 1) representing the model's confidence in each hypothesis ground truth: A single trajectory of T [x, y] coordinate pairs Compute and return a dictionary with the following keys: ade per hypothesis: list of Average Displacement Error for each hypothesis (mean Euclidean distance across all timesteps) fde per hypothesis: list of Final Displacement Error for each hypothesis (Euclidean distance at the last timestep only) min ade: the minimum ADE across all hypotheses min fde: the minimum FDE across all hypotheses best hypothesis idx: index of the hypothesis with the lowest ADE wta loss: the winner takes all loss, equal to the ADE of the best hypothesis prob weighted ade: the sum of each hypothesis's probability multiplied by its ADE All float values in the returned dictionary should be rounded to 4 decimal places.