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

How can I use NASLib with my own data? #150

Open
JuliaWasala opened this issue Dec 19, 2022 · 1 comment
Open

How can I use NASLib with my own data? #150

JuliaWasala opened this issue Dec 19, 2022 · 1 comment

Comments

@JuliaWasala
Copy link

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

@jr2021
Copy link
Collaborator

jr2021 commented Feb 5, 2023

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

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