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.8-py38-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9491a4d6dc2a7f45e3ab45e35c842b2233d2d0e6c736d14ceb0263f498336013 |
|
MD5 | d07768bdc35c7e2cdd000d9383604ae6 |
|
BLAKE2b-256 | c48bd038ff19c6bf1ead4335ba37ef3e21670d5c32c83bec5d2fb038a380a622 |
Hashes for pytorch_datastream-0.3.8-py37-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cecef8a9a44f846888dbeb6e2f58e1c9ef0f9b3a7029ff6815c2063c0baa3ce2 |
|
MD5 | 15b91fe0400116429b5d754c75d4b54d |
|
BLAKE2b-256 | cf7d22605647e8152fdfa9b74f1aaa33b23e5cf51718e684b5e681bf9785ad2e |
Hashes for pytorch_datastream-0.3.8-py36-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7484925a78c6cd49e608f4363293cb66fdb13ecd5ce04665f21756a7519fb6f6 |
|
MD5 | 41781f0f28a892934a5378e3eb2bb0c7 |
|
BLAKE2b-256 | 00c4d0a4c7615df90779d3fea96f3c4d774344251acffa75752adbb4c48a6e69 |