Unweighted loss ignores class imbalance
An AI wrote this PyTorch training step for a 1:200 imbalanced defect-detection model. Loss decreases smoothly but the model predicts 'no defect' almost always. Explain why and fix it.
Implement
select_f1_threshold(scores: list[float], labels: list[int], thresholds: list[float]) → floatExamples
in
[[0.1,0.2,0.05,0.4],[0,1,0,1],[0.5,0.3,0.15]]out0.15in
[[0.2,0.7],[0,0],[0.9,0.5]]out0.9in
[[0.42,0.38,0.44,0.05,0.02],[1,0,1,0,0],[0.5,0.4]]out0.4What a strong answer looks like
Treat the AI’s output as a draft to verify, not an answer to trust. Name the specific flaw and the input that triggers it, say how you’d catch it (tests, edge cases, reading critically), and how you’d re-prompt or decompose to get it right.
0:00 of about 17 min
Vibe & agentic: describe the solution in plain language (or narrate it) and the coach grades your approach.
Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.
Run or narrate your approach, then ask the coach.