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) usingCrossEntropyLoss. - Dataloaders yield
(image_tensor, target)pairs wheretargetis integer-encoded (0/1). - Uses CUDA if available, otherwise CPU.
Hyperparameters
- Optimizer:
Adam(lr=MY_OPTIM_LR)withMY_OPTIM_LR = 1e-3. - Epochs:
MY_EPOCHS = 3.
Attributes:
| Name | Type | Description |
|---|---|---|
train_set |
DataLoader[VisionDataset]
|
Set during |
test_set |
DataLoader[VisionDataset]
|
Set during |
device |
device
|
|
model |
Module
|
The classifier (initialized in |
criterion |
Module
|
Loss function ( |
optimizer |
Optimizer
|
Adam optimizer on |