automl/NASLib

How can I use NASLib with my own data?

Opened this issue · 1 comments

Hi, I'd like to use NASLib with my own dataset. Is there an option to do that?

jr2021 commented

Hi Julia,

Thanks for your question. NASLib does not natively support custom datasets, so we added this as a feature.

We've created a class at naslib/utils/custom_dataset.py which allows you to use your own dataset. An example of how to use this class can be found at examples/custom_data.py. You can also find a code snippet from this example below:

class MyCustomDataset(CustomDataset):
        def __init__(self, config, mode="train"):
            super().__init__(config, mode)


        def get_transforms(self, config):
            train_transform, valid_transform = _data_transforms_cifar10(config)
            return train_transform, valid_transform
            

        def get_data(self, data, train_transform, valid_transform):
            train_data = dset.CIFAR10(
                root=data, train=True, download=True, transform=train_transform
            )
            test_data = dset.CIFAR10(
                root=data, train=False, download=True, transform=valid_transform
            )

            return train_data, test_data
            
    config = get_config_from_args()
    dataset = MyCustomDataset(config)
    train_queue, valid_queue, test_queue, train_transform, valid_transform = dataset.get_loaders()
    

Let us know if you have any further questions :)

Best,
Jake, on behalf of the NASLib team