Flower Datasets
Flower Datasets (flwr-datasets) is a library to quickly and easily create datasets for federated learning, federated evaluation, and federated analytics. It was created by the Flower Labs team that also created Flower: A Friendly Federated AI Framework.
[!TIP] For complete documentation that includes API docs, how-to guides and tutorials, please visit the Flower Datasets Documentation and for full FL example see the Flower Examples page.
Installation
For a complete installation guide visit the Flower Datasets Documentation
pip install flwr-datasets[vision]
Overview
Flower Datasets library supports:
- downloading datasets - choose the dataset from Hugging Face's
datasets, - partitioning datasets - customize the partitioning scheme,
- creating centralized datasets - leave parts of the dataset unpartitioned (e.g. for centralized evaluation).
Thanks to using Hugging Face's datasets used under the hood, Flower Datasets integrates with the following popular formats/frameworks:
- Hugging Face,
- PyTorch,
- TensorFlow,
- Numpy,
- Pandas,
- Jax,
- Arrow.
Create custom partitioning schemes or choose from the implemented partitioning schemes:
- Partitioner (the abstract base class)
Partitioner - IID partitioning
IidPartitioner(num_partitions) - Dirichlet partitioning
DirichletPartitioner(num_partitions, partition_by, alpha) - Distribution partitioning
DistributionPartitioner(distribution_array, num_partitions, num_unique_labels_per_partition, partition_by, preassigned_num_samples_per_label, rescale) - InnerDirichlet partitioning
InnerDirichletPartitioner(partition_sizes, partition_by, alpha) - Pathological partitioning
PathologicalPartitioner(num_partitions, partition_by, num_classes_per_partition, class_assignment_mode) - Natural ID partitioning
NaturalIdPartitioner(partition_by) - Size based partitioning (the abstract base class for the partitioners dictating the division based the number of samples)
SizePartitioner - Linear partitioning
LinearPartitioner(num_partitions) - Square partitioning
SquarePartitioner(num_partitions) - Exponential partitioning
ExponentialPartitioner(num_partitions) - more to come in the future releases (contributions are welcome).
Comparison of Partitioning Schemes on CIFAR10
PS: This plot was generated using a library function (see flwr_datasets.visualization package for more).
Usage
Flower Datasets exposes the FederatedDataset abstraction to represent the dataset needed for federated learning/evaluation/analytics. It has two powerful methods that let you handle the dataset preprocessing: load_partition(partition_id, split) and load_split(split).
Here's a basic quickstart example of how to partition the MNIST dataset:
from flwr_datasets import FederatedDataset
from flwr_datasets.partitioners import IidPartitioner
# The train split of the MNIST dataset will be partitioned into 100 partitions
partitioner = IidPartitioner(num_partitions=100)
fds = FederatedDataset("ylecun/mnist", partitioners={"train": partitioner})
partition = fds.load_partition(0)
centralized_data = fds.load_split("test")
For more details, please refer to the specific how-to guides or tutorials. They showcase customization and more advanced features.
Metadata
Release files for flwr-datasets 0.6.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| flwr_datasets-0.6.1.tar.gz | 54.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| flwr_datasets-0.6.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 148.1 kB
Release files / flwr_datasets-0.6.1.tar.gz
| Download URL | flwr_datasets-0.6.1.tar.gz |
|---|---|
| Size | 54.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8692e24209e0780bc869f414d3e9c5d3d8a2fe0928c488b3bb7ec28aebf7f3e6
|
|
BLAKE2b-256 checksum How to use checksums |
fb343ccc520d4c73d9a75c572763ea0e107928dde6fb7ea8152877c05c94bf6e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / flwr_datasets-0.6.1-py3-none-any.whl
| Download URL | flwr_datasets-0.6.1-py3-none-any.whl |
|---|---|
| Size | 93.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4fd98cfadd25ddf3a64131ea9fdf63a830ad11b375e92cd892902953c9aa920b
|
|
BLAKE2b-256 checksum How to use checksums |
9a7178b09bed04060c6062319ebd3390a843897de28fafb07ea292f24701e658
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|