HAL-42 / AlchemyCat

Alchemy Cat —— 🔥Config System for SOTA
https://github.com/HAL-42/AlchemyCat
Apache License 2.0
123 stars 10 forks source link

自定义的dataset怎么使用? #6

Open Azai-yx opened 3 months ago

Azai-yx commented 3 months ago

之前没有太多的调参经验,想知道像这里的MNIST如果要替换成自己的dataset的话大致需要怎么做?

-- [INCOMPLETE] configs/mnist/plain_usage/cfg.py --

from torchvision.datasets import MNIST from alchemy_cat.dl_config import Config

cfg = Config()

cfg.rand_seed = 0

cfg.dt.cls = MNIST cfg.dt.ini.root = '/tmp/data' cfg.dt.ini.train = True

... Code Omitted.

HAL-42 commented 3 months ago

最直接的办法,就是直接修改configs/mnist/plain_usage/cfg.py。以改为 CIFAR10 数据集为例,只需要修改cfg.dt下的配置项:

cfg.dt.cls = CIFAR10
cfg.dt.ini.root = '/tmp/data'
cfg.dt.ini.transform = T.Compose([T.ToTensor(), T.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))])

不过,我们更推荐参考继承一节中的例子,写一个新配置,新配置继承configs/mnist/plain_usage/cfg.py,但将数据集修改为自定义数据集。还是以改为 CIFAR10 为例:

-- configs/CIFAR10/cfg.py --
from alchemy_cat.dl_config import Config

import torchvision.transforms as T
from torchvision.datasets import CIFAR10

cfg = Config(caps='configs/mnist/plain_usage/cfg.py')

cfg.dt.override()
cfg.dt.cls = CIFAR10
cfg.dt.ini.root = '/tmp/data'
cfg.dt.ini.transform = T.Compose([T.ToTensor(), T.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))])