Skip to content
All projects

In development · 2026

AI-Generated Image Detector

A CNN with the convolution layer written from scratch in NumPy.

The problem

Detectors that score well on one generator collapse on the next. The question is not "can you classify?" but "does the signal generalize across generators?"

What I built

A CNN whose convolution layer is implemented from scratch in NumPy and verified with gradient checking, used as a controlled testbed for cross-generator generalization.

Why write convolution by hand

Calling Conv2d teaches you the API. Writing the backward pass yourself and validating it against numerical gradients teaches you where the signal actually comes from, which matters when the question you care about is which features transfer to a new generator.

The generalization trap

Training and testing on the same generator produces flattering numbers driven by generator-specific artifacts. Evaluation is split by generator, so held-out performance measures the thing that would matter in deployment.

Outcome

  • Convolution forward/backward verified by gradient checking
  • Cross-generator generalization framed as the core empirical question
  • No framework autograd, so every gradient is accounted for

Stack

PythonNumPy

Data flow

From-scratch CNN with gradient verification

  1. 1

    Data

    Real vs generated images, split by generator

  2. 2

    Conv layer (NumPy)

    Hand-written forward + backward pass

  3. 3

    Gradient check

    Numerical vs analytical gradient agreement

  4. 4

    Train loop

    Manual backprop, no autograd

  5. 5

    Held-out generator eval

    Generalization measured across generators

PythonNumPy

This diagram is generated from portfolio.ts. Edit the `architecture` field to change it.

Want the deeper version of this?

I am happy to walk through the tradeoffs, the failure modes, and what I would do differently.

Email me