Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Azai-yx opened this issue Jul 30, 2024 · 1 comment
Open

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

Azai-yx opened this issue Jul 30, 2024 · 1 comment

Comments

@Azai-yx
Copy link

Azai-yx commented Jul 30, 2024

之前没有太多的调参经验,想知道像这里的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
Copy link
Owner

HAL-42 commented Jul 30, 2024

最直接的办法,就是直接修改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))])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants