Skip to content

simet.metrics.downstream_task.sample.sample_downstream_task

simet.metrics.downstream_task.sample.sample_downstream_task

SampleDownstreamTask

Bases: DownstreamTask, ABC

Toy downstream task: train a small CNN and report test accuracy.

Trains a :class:SimpleCNN classifier for a few epochs on a provided training dataloader and evaluates on a test dataloader, returning the final accuracy as a scalar. Intended as a lightweight example of how to wire a downstream task; not optimized for performance.

Assumptions
  • Binary classification (num_classes=2) using CrossEntropyLoss.
  • Dataloaders yield (image_tensor, target) pairs where target is integer-encoded (0/1).
  • Uses CUDA if available, otherwise CPU.
Hyperparameters
  • Optimizer: Adam(lr=MY_OPTIM_LR) with MY_OPTIM_LR = 1e-3.
  • Epochs: MY_EPOCHS = 3.

Attributes:

Name Type Description
train_set DataLoader[VisionDataset]

Set during _compute.

test_set DataLoader[VisionDataset]

Set during _compute.

device device

"cuda" if available else "cpu".

model Module

The classifier (initialized in _compute).

criterion Module

Loss function (CrossEntropyLoss).

optimizer Optimizer

Adam optimizer on model params.