Code Room
Vibe codingMediumvc-g262
Subject Ai code reviewLevel Mid–Senior~17 minCommon in Algorithms & data structures interviewsIndustries Technology

Question

An AI claimed this PyTorch setup makes training 'fully reproducible,' but two runs give different validation scores. Identify what's missing.

python
import torch, numpy as np torch.manual_seed(42) train_loader = DataLoader(ds, batch_size=64, shuffle=True, num_workers=4)model = Net().to('cuda')for epoch in range(10):    for xb, yb in train_loader:        loss = loss_fn(model(xb), yb)        loss.backward(); opt.step(); opt.zero_grad()
What 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.

Describe your solution

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.