Loss Functions, Behaviors & Selection Questions
Loss function design, evaluation, and selection in machine learning. Includes common loss functions (MSE, cross-entropy, hinge, focal loss), how loss properties affect optimization and gradient flow, issues like class imbalance and label noise, calibration, and practical guidance for choosing the most appropriate loss for a given task and model.
HardTechnical
148 practiced
Design a composite loss for multi-object tracking that includes (1) detection classification loss, (2) bounding-box regression loss (L1/GIoU), (3) identity consistency loss (e.g., cross-entropy over track IDs or triplet loss), and (4) motion smoothness regularizer. Explain weighting strategy, staged vs joint training, and how you would validate each component in offline and online evaluation.
EasyTechnical
99 practiced
Implement a numerically stable binary cross-entropy (BCE) loss in Python using NumPy. Function signature: def binary_bce_loss(logits: np.ndarray, targets: np.ndarray, reduction: str = 'mean') -> float. logits are raw model outputs (floats), targets are 0/1. Support 'none', 'mean', and 'sum' reductions and avoid overflow/underflow when computing terms.
MediumTechnical
98 practiced
When your target metric is non-differentiable (for example F1 score or top-k accuracy), explain practical strategies to train models: use surrogate losses, structured prediction with task-specific losses, reinforcement learning approaches (policy gradients), or threshold optimization after training. For each strategy, list pros, cons, and production complexity.
HardSystem Design
142 practiced
You need to optimize NDCG for a large-scale search system. Propose differentiable surrogates (softmax-based approximations, LambdaRank), sampling strategies to estimate gradients efficiently, and distributed training architecture considerations to scale to billions of pairs. Discuss offline vs online evaluation trade-offs and how to validate improvements safely.
HardTechnical
149 practiced
Training loss is decreasing but validation metrics are plateauing or degrading—diagnose a scenario where label noise or memorization is occurring. Provide a step-by-step debugging and remediation plan: per-example loss histograms, small-loss selection, co-teaching, early stopping, semi-supervised learning, relabeling, and production safeguards to prevent deploying a memorized model.
Unlock Full Question Bank
Get access to hundreds of Loss Functions, Behaviors & Selection interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.