-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* modify sampler * add split dataset example
- Loading branch information
Showing
3 changed files
with
87 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import pandas as pd | ||
|
||
from iflearner.datasets.mnist import MNIST | ||
from iflearner.datasets.sampler import Sampler | ||
|
||
|
||
clients = ['party1', 'party2', 'party3'] | ||
dataset = MNIST('./data', True) | ||
sampler = Sampler(dataset.train_labels, clients, 'dirichlet', alpha=2) | ||
clients_index = sampler.client_index | ||
|
||
d = {} | ||
for name, index in clients_index.items(): | ||
index = list(index) | ||
p = pd.Series(dataset.train_labels[index].astype('int64')) | ||
|
||
print(name+'各个类别:') | ||
print(p.value_counts()) | ||
print() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters