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
disentanglement-pytorch: Variational autoencoder models for disentanglement, created as a contribution to the Disentanglement Challenge of NeurIPS 2019, along with more datasets with a different interface.disentanglement_lib: VAE models, metrics, and data for disentanglement, implemented in TensorFlow, created as a contribution to the Disentanglement Challenge of NeurIPS 2019.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pytorch-disentanglement-datasets-0.0.1.tar.gz.
File metadata
- Download URL: pytorch-disentanglement-datasets-0.0.1.tar.gz
- Upload date:
- Size: 6.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c2aad324bd93d2ffe93eed1c36bf74b4dbd6475c2079d4b365be643fa79c93b8
|
|
| MD5 |
c7a8393ca25451921d7f762d68d53718
|
|
| BLAKE2b-256 |
4f84917aa260abcb80842cff1cb3b9711fcfec803e493d3ab0e229afcd98e269
|
File details
Details for the file pytorch_disentanglement_datasets-0.0.1-py3-none-any.whl.
File metadata
- Download URL: pytorch_disentanglement_datasets-0.0.1-py3-none-any.whl
- Upload date:
- Size: 7.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0283e40e2f49f3ec44a9841ce6b986e87d7229c8baa4c3631d0b9c9d056dc838
|
|
| MD5 |
6bfa39f9180ffa6ceb5fe10a08b28fee
|
|
| BLAKE2b-256 |
a57337fd6a6b696ae7fbcdd1aed04b0e0ff2036c36862bb613e1e950a4152483
|