Simple dataset to dataloader library for pytorch
Project description
This is a simple library for creating readable dataset pipelines and reusing best practices for issues such as imbalanced datasets. There are just two components to keep track of: Dataset and Datastream.
Dataset is a simple mapping between an index and an example. It provides pipelining of functions in a readable syntax originally adapted from tensorflow 2’s tf.data.Dataset.
Datastream combines a Dataset and a sampler into a stream of examples. It provides a simple solution to oversampling / stratification, weighted sampling, and finally converting to a torch.utils.data.DataLoader.
Install
pip install pytorch-datastream
Usage
The list below is meant to showcase functions that are useful in most standard and non-standard cases. It is not meant to be an exhaustive list. See the documentation for a more extensive list on API and usage.
Dataset.from_subscriptable
Dataset.from_dataframe
Dataset
.map
.subset
.split
.cache
.with_columns
Datastream.merge
Datastream.zip
Datastream
.map
.data_loader
.zip_index
.update_weights_
.update_example_weight_
.weight
.state_dict
.load_state_dict
Merge / stratify / oversample datastreams
The fruit datastreams given below repeatedly yields the string of its fruit type.
>>> datastream = Datastream.merge([
... (apple_datastream, 2),
... (pear_datastream, 1),
... (banana_datastream, 1),
... ])
>>> next(iter(datastream.data_loader(batch_size=8)))
['apple', 'apple', 'pear', 'banana', 'apple', 'apple', 'pear', 'banana']
Zip independently sampled datastreams
The fruit datastreams given below repeatedly yields the string of its fruit type.
>>> datastream = Datastream.zip([
... apple_datastream,
... Datastream.merge([pear_datastream, banana_datastream]),
... ])
>>> next(iter(datastream.data_loader(batch_size=4)))
[('apple', 'pear'), ('apple', 'banana'), ('apple', 'pear'), ('apple', 'banana')]
More usage examples
See the documentation for more usage examples.
Install from source
To patch the code locally for Python 3.6 run patch-python3.6.sh.
$ ./patch-python3.6.sh
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 Distributions
Built Distributions
Hashes for pytorch_datastream-0.4.2-py39-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7bbf4a0494faf9acaf0eeb53c90ceb705c0b2b6ec75d90f5f94a6428788a1f8e |
|
MD5 | 59c41b4f15ce3f0def7070dba618aac9 |
|
BLAKE2b-256 | b841c46315d82f4c8de8d97dc6051915d99f83099b7cfbd5fff94b32723e1a57 |
Hashes for pytorch_datastream-0.4.2-py38-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b306717661761de0af81bfa73ed5679523e1b2aa075214eb285b847ad2b0fb0a |
|
MD5 | 9c05f4f60b9b26e3a08c4c7e06d3e120 |
|
BLAKE2b-256 | cf35ea01cb1bbf9b4429690d9661211e877ed74adb4d8614dad677d47c5263bc |
Hashes for pytorch_datastream-0.4.2-py37-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 75dd9b69b03473c5dc122987366cb2c144f0e36e07f270c2cc824ce69cc44996 |
|
MD5 | dec856575949f146b857d42d00a03e82 |
|
BLAKE2b-256 | 876add3fb4f5a25c8765d6ac0b7863c626b5f2ea9a4b486f97830cdc752afc9e |
Hashes for pytorch_datastream-0.4.2-py36-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 67b7f7ab3d74ef4f28354cb4adedc7a7ebead66b021eec11a515deb97bb93cec |
|
MD5 | b6487f720fb440df52abd18a68b33400 |
|
BLAKE2b-256 | efab99dd9ead3f7ebaa9e460231e97c8deb9d9b8de97618881e3f466090cefbc |