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.3.10-py38-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 544887b901731d3933c39695c355e5c524dc3d9586ee6b5ac0b9c56fc5c86a60 |
|
MD5 | a5ef9264f87e7d95f24bb8a1d202e48c |
|
BLAKE2b-256 | 7b3329d439ec81397c72c3010ac886005f5061c536de0be0a16f6121e9e4ee6c |
Hashes for pytorch_datastream-0.3.10-py37-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | eafb32ed72ac0f2c4f5f956d2131793e77afc1e82ebaecc55bf7e75f9e0a0774 |
|
MD5 | 24f96d62866ac38563490f271843d589 |
|
BLAKE2b-256 | 872006e542dd72e549064783c0f8d4d9bf893a4c40c78dd1ff3b0c05796b3997 |
Hashes for pytorch_datastream-0.3.10-py36-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 49dce97ac32de29277b7a2044d1053ae579db2700664bbc109866584aff9e2f3 |
|
MD5 | 091928980eaf35c11c2245a55e578f8d |
|
BLAKE2b-256 | 91637afba70cb6365754e33268b5af2ccd69508f92cdcedfa1344088a12e774a |