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.9-py38-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 58b14fe0b1275b6aaff278f2fd5dae70d2359e25ad134181b2a83f36834f26c4 |
|
MD5 | 4584b8f70d588b8be3bfa3cba82dd7d0 |
|
BLAKE2b-256 | 5506eb388a8528149e79be131c5b4fa529bfd8d7d7c98d8bc522746c8afbd04c |
Hashes for pytorch_datastream-0.3.9-py37-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0a9c6d940814be132778b3ece2810850df04b5c0e9ce348510d57ae56b99e802 |
|
MD5 | 2f0cada2e60bb3a60f03a1bc49c9b037 |
|
BLAKE2b-256 | 7eb0d56f890a76f5fc4075b940d0d3206653d5837d9389d3d1536dd34541d688 |
Hashes for pytorch_datastream-0.3.9-py36-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 11eccaf818d65f1449aea757125b1e2fc164eb36ff4093dd1a8347def3bdbb5d |
|
MD5 | 833b1e33be5675a19ec822005769690b |
|
BLAKE2b-256 | 8e2b66c128c6d0da78271a34bfc5df99e2d41d8af4966187dc0dd3497b69abdd |