InterviewStack.io LogoInterviewStack.io

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.

EasyTechnical
0 practiced
Explain why combining softmax and cross-entropy into a single stable operation improves numeric stability. Describe the log-sum-exp trick and implement a numerically-stable log-sum-exp function in Python that accepts a 2D array of logits (batch × classes) and reduces over the class axis. Discuss how you would vectorize it for large batches.
MediumTechnical
0 practiced
You are handed a binary classification dataset where the positive class is 1% of examples. Design an experiment to decide between class weighting, focal loss, and oversampling. Specify dataset splits, validation metric(s), training setup, baselines, and what signals you'd monitor to make a decision for production deployment.
MediumTechnical
0 practiced
Implement focal loss for multi-class classification in PyTorch. Provide a function with signature def focal_loss(logits, targets, gamma=2.0, alpha=None, reduction='mean') where logits are raw scores (batch × classes) and targets are integer class indices. Support optional per-class alpha weights and reductions 'none'|'mean'|'sum', and ensure numerical stability.
MediumSystem Design
0 practiced
Design a monitoring system that tracks per-class loss, loss decomposition (e.g., classification vs regression terms), gradient norms, and concept drift signals in production. Specify what to log (granularity), retention policies, alerting thresholds, sample rates, dashboards, and how to tie observed loss changes to upstream data or code changes.
MediumTechnical
0 practiced
Explain what a proper scoring rule is and why cross-entropy (log-loss) is a proper scoring rule for probabilistic forecasts. Describe how proper scoring rules encourage truthful probability estimates and why that property matters for downstream decision-making and calibration.

Unlock Full Question Bank

Get access to hundreds of Loss Functions, Behaviors & Selection interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.