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.7-py38-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 07b8c598a7f5135573ef85b5e1324f8f81544e7c512dbce2cfb32f7de1eba6bc |
|
MD5 | ce50704a6952310bf53cc9d4c7df1941 |
|
BLAKE2b-256 | fcba7f491ca70dbf56d2c40ed89a15606063c2b1c8d5d8b55c96b74c2d2cdad2 |
Hashes for pytorch_datastream-0.3.7-py37-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6f2661a97a2e7e61d41615e5a2359d92be72eff7b5628ba2719f6d40da8af66d |
|
MD5 | 8a82180d015c8ddea483e553bcd9501d |
|
BLAKE2b-256 | 403a1653e4baec4d4e67a945e19d75b2ab5e6b508131faa0851726a3ad856c91 |
Hashes for pytorch_datastream-0.3.7-py36-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a277c9ccc7c7d9b37c75bb2ad10065a37551f2efd77effa4741d48b99c79fb7c |
|
MD5 | 5dd787c2de0f8b52b6766397e1575157 |
|
BLAKE2b-256 | 34d056d764a4c6cad92804d4be56ef5318862977b3952f922164b81658386bdf |