Skip to content
Aabha AI Academy
Skip to reading

Deep Learning

Stages

"""Complete one function at a time, then run python check_learner.py.
Public tests assess YOUR functions. Unimplemented stages fail intentionally.
"""
import torch
from torch import nn

def predict_batch(x, w, b):
    """Stage 1: X[N,D], W[D,1], b[1] -> prediction[N,1]."""
    raise NotImplementedError('Implement the affine map.')

def fit_standardizer(x_train):
    """Stage 2: return (mean[D], scale[D]); population std, clamp >= 1e-8."""
    raise NotImplementedError('Fit using only the supplied training rows.')

def make_classifier():
    """Stage 3: 2 -> 16 -> 1 MLP with ReLU, returning RAW logits [N,1]."""
    raise NotImplementedError('Build an nn.Sequential.')

def training_step(model, optimizer, xb, yb):
    """Stage 4: zero gradients, forward, BCE logits loss, backward, step; return float loss."""
    raise NotImplementedError('Implement one optimizer update.')

def infer_probabilities(model, xb):
    """Stage 5: eval mode, no gradient recording, sigmoid of raw logits [N,1]."""
    raise NotImplementedError('Keep inference free of autograd graphs.')

Download this source file