from fastai.vision.all import *
path = untar_data(URLs.MNIST_SAMPLE)
mnist = DataBlock(
    blocks=(ImageBlock(PILImageBW), CategoryBlock),
    get_items=get_image_files,
    splitter=GrandparentSplitter(),
    get_y=parent_label
)
dls = mnist.dataloaders(path, bs=256)
learn = vision_learner(dls, resnet18, metrics=accuracy)
learn.fit_one_cycle(1, 1e-2)
/home/doyu/mambaforge/lib/python3.9/site-packages/torchvision/models/_utils.py:135: UserWarning: Using 'weights' as positional parameter(s) is deprecated since 0.13 and will be removed in 0.15. Please use keyword parameter(s) instead.
  warnings.warn(
/home/doyu/mambaforge/lib/python3.9/site-packages/torchvision/models/_utils.py:223: UserWarning: Arguments other than a weight enum or `None` for 'weights' are deprecated since 0.13 and will be removed in 0.15. The current behavior is equivalent to passing `weights=ResNet18_Weights.IMAGENET1K_V1`. You can also use `weights=ResNet18_Weights.DEFAULT` to get the most up-to-date weights.
  warnings.warn(msg)
epoch train_loss valid_loss time
0 0.134366 0.039583 00:13
learn = vision_learner(dls, resnet18, metrics=accuracy)
learn.fine_tune(1, 1e-2)
epoch train_loss valid_loss accuracy time
0 0.300083 0.125544 0.955839 00:13
epoch train_loss valid_loss accuracy time
0 0.039169 0.032611 0.992149 01:27