# Agent brief: Train ClothingCNN on Fashion-MNIST

- **Lesson id:** 02
- **Goal:** Train and save the shared ClothingCNN weights on Mac MPS or CPU.
- **Prerequisites:** Python 3.11+, `uv`, macOS, [human lesson](02-train-clothingcnn.html).
- **Inputs:** Empty Python project.
- **Outputs/artifacts:** `clothing.pt`, `train.py`, and passing tensor checks.

## Steps

1. Run `uv init --python 3.11`, `uv venv`, and `uv add torch torchvision`.
2. Use `FashionMNIST`, `ToTensor()`, the two-convolution/two-linear `ClothingCNN`, cross-entropy, and Adam.
3. Pick `mps` when it is available, otherwise `cpu`. Never add CUDA.
4. Move the trained model to CPU, save `clothing.pt`, and check that a zero input `[1,1,28,28]` float32 produces `[1,10]` float32.
5. Keep the fixed label order from the lesson.

## Constraints

Keep preprocessing in `[0,1]`. Do not apply softmax to logits during training. Do not rewrite other courses.

## Key concepts

- Fashion-MNIST is 28x28 grayscale images and ten clothing classes in a fixed order.
- `ClothingCNN` uses `ToTensor()` so pixels are float32 in 0-1.
- Pick `mps` when available, else `cpu`. No CUDA.
- Move the model to CPU, save `clothing.pt`, and check shapes `[1, 1, 28, 28]` in and `[1, 10]` out.

## Takeaways

- Keep the `ClothingCNN` class. Linux conversion needs the same definition.
- Do not apply softmax during training. Cross-entropy expects raw logits.
- Copy `clothing.pt` to the Linux host before lesson 03.

## Acceptance checks

`uv run python train.py` finishes, the weights reload into the same class, and the [human lesson](02-train-clothingcnn.html) stays linked.
