TsingZ0 / PFLlib

37 traditional FL (tFL) or personalized FL (pFL) algorithms, 3 scenarios, and 20 datasets.
GNU General Public License v2.0
1.45k stars 300 forks source link

关于使用Shakespeare数据集的问题 #200

Closed chenzhigang00 closed 2 months ago

chenzhigang00 commented 3 months ago

感谢分享!这个仓库真的很好用!不过当我想使用这个框架察看FedAvg算法和lstm模型在Shakespeare数据集上的实验效果时,发现generate_Shakespeare.py文件和generate_MNIST.py文件有些区别,最终没能成功运行也找不出原因,不知如何是好,希望能得到一些建议!

image

Traceback (most recent call last):
  File "D:\PFLlib-master\PFLlib-master\system\main.py", line 541, in <module>
    run(args)
  File "D:\PFLlib-master\PFLlib-master\system\main.py", line 373, in run
    server.train()
  File "D:\PFLlib-master\PFLlib-master\system\flcore\servers\serveravg.py", line 48, in train
    self.evaluate()
  File "D:\PFLlib-master\PFLlib-master\system\flcore\servers\serverbase.py", line 246, in evaluate
    stats = self.test_metrics()
  File "D:\PFLlib-master\PFLlib-master\system\flcore\servers\serverbase.py", line 220, in test_metrics
    ct, ns, auc = c.test_metrics()
  File "D:\PFLlib-master\PFLlib-master\system\flcore\clients\clientbase.py", line 125, in test_metrics
    output = self.model(x)
  File "E:\Anaconda3\envs\pfllib\lib\site-packages\torch\nn\modules\module.py", line 1501, in _call_impl
    return forward_call(*args, **kwargs)
  File "D:\PFLlib-master\PFLlib-master\system\flcore\trainmodel\models.py", line 34, in forward
    out = self.base(x)
  File "E:\Anaconda3\envs\pfllib\lib\site-packages\torch\nn\modules\module.py", line 1501, in _call_impl
    return forward_call(*args, **kwargs)
  File "D:\PFLlib-master\PFLlib-master\system\flcore\trainmodel\models.py", line 431, in forward
    text, text_lengths = x
ValueError: too many values to unpack (expected 2)

通过调试,我发现最后text, text_lengths = xx的值为一个(10,80)大小的张量Tensor

image

我的参数设置是这样的:-data Shakespeare -m lstm -algo FedAvg -gr 2000 -did 0 -ls 5 -jr 0.1 -lr 1.47 -lbs 10

TsingZ0 commented 2 months ago

前2个问题已经修复,第三个问题是因为我们直接使用的LEAF的切分,所以不需要设置参数