TsingZ0 / PFLlib

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

模型保存错误 #197

Closed timohaha closed 2 months ago

timohaha commented 2 months ago

在训练完成后,训练结果无法保存`Average time cost: 1043.5s.

Traceback (most recent call last):

File "/tmp/pycharm_project_711/system/main.py", line 540, in run(args)

File "/tmp/pycharm_project_711/system/main.py", line 366, in run average_data(dataset=args.dataset, algorithm=args.algorithm, goal=args.goal, times=args.times)

File "/tmp/pycharm_project_711/system/utils/result_utils.py", line 24, in average_data test_acc = get_all_results_for_one_algo(algorithm, dataset, goal, times) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/tmp/pycharm_project_711/system/utils/result_utils.py", line 39, in get_all_results_for_one_algo test_acc.append(np.array(read_data_then_delete(file_name, delete=False))) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/tmp/pycharm_project_711/system/utils/result_utils.py", line 47, in read_data_then_delete with h5py.File(file_path, 'r') as hf: ^^^^^^^^^^^^^^^^^^^^^^^^^

File "/home/b810/miniconda3/envs/fl/lib/python3.11/site-packages/h5py/_hl/files.py", line 562, in init fid = make_fid(name, mode, userblock_size, fapl, fcpl, swmr=swmr) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/home/b810/miniconda3/envs/fl/lib/python3.11/site-packages/h5py/_hl/files.py", line 235, in make_fid fid = h5f.open(name, flags, fapl=fapl) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper

File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper

File "h5py/h5f.pyx", line 102, in h5py.h5f.open

FileNotFoundError: [Errno 2] Unable to open file (unable to open file: name = '../results/Cifar10_FedCP_test_0.h5', errno = 2, error message = 'No such file or directory', flags = 0, o_flags = 0)

timohaha commented 2 months ago

找到了问题,servercp.py没有添加self.save_results()