Skip to main content

PyTorch datasets with a focus on disentanglement

Project description

Disentanglement Datasets

A lightweight package of torchvision-style PyTorch datasets with a focus on flexibility.

Installation

$ pip install pytorch-disentanglement-datasets

Usage

Each dataset returns a dictionary containing at least an input key:

>>> from disentanglement_datasets import DSprites
>>> dataset = DSprites(root="./data", download=True)
>>> dataset[0]
{'input': tensor([[0, 0, 0,  ..., 0, 0, 0],
        [0, 0, 0,  ..., 0, 0, 0],
        [0, 0, 0,  ..., 0, 0, 0],
        ...,
        [0, 0, 0,  ..., 0, 0, 0],
        [0, 0, 0,  ..., 0, 0, 0],
        [0, 0, 0,  ..., 0, 0, 0]], dtype=torch.uint8),
 'latent': tensor([1.0000, 1.0000, 0.5000, 0.0000, 0.0000, 0.0000], dtype=torch.float64)}

This dictionary can be transformed. For example, for self-supervised learning with augmentations you might do something like:

>>> def my_transform(item):
...   view1 = my_random_augmentation(item["input"])
...   view2 = my_random_augmentation(item["input"])
...   return view1, view2
...
>>> dataset = DSprites(root="./data", download=True, transform=my_transform)
>>> dataset[0]
(tensor([[0, 0, 0,  ..., 0, 0, 0],
        [0, 0, 0,  ..., 0, 0, 0],
        [0, 0, 0,  ..., 0, 0, 0],
        ...,
        [0, 0, 0,  ..., 0, 0, 0],
        [0, 0, 0,  ..., 0, 0, 0],
        [0, 0, 0,  ..., 0, 0, 0]], dtype=torch.uint8), tensor([[0, 0, 0,  ..., 0, 0, 0],
        [0, 0, 0,  ..., 0, 0, 0],
        [0, 0, 0,  ..., 0, 0, 0],
        ...,
        [0, 0, 0,  ..., 0, 0, 0],
        [0, 0, 0,  ..., 0, 0, 0],
        [0, 0, 0,  ..., 0, 0, 0]], dtype=torch.uint8))

Datasets and their original sources

Attribution

If this code was useful to you, please cite the original dataset (links above) and this codebase.

BibTeX

TODO

Development

Pull requests are welcome.

See also

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytorch-disentanglement-datasets-0.0.1.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file pytorch-disentanglement-datasets-0.0.1.tar.gz.

File metadata

File hashes

Hashes for pytorch-disentanglement-datasets-0.0.1.tar.gz
Algorithm Hash digest
SHA256 c2aad324bd93d2ffe93eed1c36bf74b4dbd6475c2079d4b365be643fa79c93b8
MD5 c7a8393ca25451921d7f762d68d53718
BLAKE2b-256 4f84917aa260abcb80842cff1cb3b9711fcfec803e493d3ab0e229afcd98e269

See more details on using hashes here.

File details

Details for the file pytorch_disentanglement_datasets-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for pytorch_disentanglement_datasets-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0283e40e2f49f3ec44a9841ce6b986e87d7229c8baa4c3631d0b9c9d056dc838
MD5 6bfa39f9180ffa6ceb5fe10a08b28fee
BLAKE2b-256 a57337fd6a6b696ae7fbcdd1aed04b0e0ff2036c36862bb613e1e950a4152483

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page