Package

dataset.py

Model implementation. We’ll be using a “simple” ResNet-18 for image classification here.

2022 Benjamin Kellenberger

cv4e_lecture13.dataset.load(cfg)

Load the MNIST dataset from PyTorch (download if needed) and return a DataLoader

MNIST is a sample dataset for machine learning, each image is 28-pixels high and 28-pixels wide (1 color channel)

model.py

Model implementation. We’ll be using a “simple” ResNet-18 for image classification here.

2022 Benjamin Kellenberger

class cv4e_lecture13.model.SmallModel

Bases: Module

forward(x)

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

classmethod load(cfg)
save(cfg, epoch, stats, best=False)
cv4e_lecture13.model.load(cfg)

train.py

The lecture materials for Lecture 1: Dataset Prototyping and Visualization

cv4e_lecture13.train.inference(cfg, dataloader, net, optimizer, criterion, update)

Our actual training function.

utils.py

Various utility functions used (possibly) across scripts.

2022 Benjamin Kellenberger

cv4e_lecture13.utils.init_config(config, log)
cv4e_lecture13.utils.init_logging()

Setup Python’s built in logging functionality with on-disk logging, and prettier logging with Rich

cv4e_lecture13.utils.init_seed(seed)