SMILELab-FL / FedLab

A flexible Federated Learning Framework based on PyTorch, simplifying your Federated Learning research.
https://fedlab.readthedocs.io
Apache License 2.0
728 stars 127 forks source link

如何在synthetic数据集上使用FedLab #283

Closed ahlane closed 1 year ago

ahlane commented 1 year ago

Describe the bug 您好,非常感谢你们提供了一个联邦学习的集成工具. 但是最近我在学习FedLab代码的过程中遇到以下几个问题:

通过synthetic文件夹中的main.py生成all_data/data.json 数据后,运行./preprocess.sh -s niid --sf 1.0 -k 5 -t sample --tf 0.6示例脚本进行数据采样分割。生成了rem_user_data, sampled_data, test, and train子文件夹,但是生成的文件夹都是空的。是因为在windows系统下用git bash运行脚本不成功吗?

另外, 想请问一下,tutorials中好像没有针对synthetic生成数据的示例教程. 在readme中提到"fedlab提供了将原始数据处理为DataSet并存储为pickle文件的方法。", 对于synthetic数据集生成json文件后是不是要使用 “create_datasets_and_save.sh”将数据"转成"Dataset,以pickle文件的形式存储". 但是“create_datasets_and_save.sh”这个脚本好像没有提供. 而pickle_dataset.py中存在类似函数, 请问该项功能是在这个程序中调用吗? 能否更新以下相应的示例教程?

期待您的回答, 非常感谢!

Environment Environment you use when bug appears:

  1. Python version 3.6.13
  2. PyTorch Version 1.10.2
  3. FedLab version 1.3.0
  4. code you run FedLab-master\FedLab-master\datasets\synthetic\preprocess.sh | pickle_dataset.py
  5. the detailed error empty rem_user_data, sampled_data, test, and train subfolders

builtins.RuntimeError: No leaf data json files for synthetic train data

Additional context Add any other context about the problem here.

dunzeng commented 1 year ago

Leaf的Synthetic数据与另外一篇benchmark文章相似,leaf的数据的pickle接口,因为版本更新原因,暂时未给出,我们会在后面更新。 但是,我们提供了jupyter tutorial作为示例,请参考该tutorial脚本(由于save_dict函数已在新版本中被移除,请将save_dict函数替换为torch.load())。 如果仍然想使用Leaf的Synthetic数据集,我们建议阅读这部分代码。

dunzeng commented 1 year ago

Synthetic dataset 接口已更新。

  1. cd datasets/synthetic/
  2. python main.py -num-tasks 1000 -num-classes 5 -num-dim 60

生成原始数据集后,调用SytheticDataset预处理并生成fedlab dataset用于后续实验。

ahlane commented 1 year ago

非常感谢,已星已引用:)