You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I run main_fedIPR.py", it report an error "AttributeError: 'DatasetSplit' object has no attribute 'classes'". Is that missing a function "classes" in the Class 'DatasetSplit'? Hope to hear you. Thank you. @purp1eHaze
The text was updated successfully, but these errors were encountered:
在试图跑非iid场景时,我也遇到了这个问题。以下是我解决这个问题的思路:
代码的编写者使用自定义的DatasetSplit类(在datasets.py中)将Dataset进行了包装。具体来说,DatasetSplit中储存的每一条数据都有一个id。id是为了方便将数据分配给不同的客户端,以模拟联邦学习的场景。
在出现问题的代码(在我这里,导致该问题的代码是sampling.py中的cifar_beta方法)处,编写者使用名为dataset的变量接住传入的DatasetSplit类对象。然而,DatasetSplit是对Dataset类的包装。编写者似乎忘了dataset它是DatasetSplit对象,而误认为它是Dataset对象。想要正确的使用该方法,你需要将出现的dataset.classes改为dataset.dataset.classes。将dataset.targets改为dataset.dataset.targets。此外,在最后的for循环“for i in range(n_clients):”中,你要将client_datasets.append(subset)改为client_datasets.append(client_i_idx)。这是因为在iid场景对应的方法cifar_iid中,返回的对象是包含id的二级列表。在别的方法中会使用这个列表对数据集进行切分。然而,在cifar_beta中,编写者已经使用client_i_idx对数据集进行切分,并返回切分后的Subset对象组成的列表。这是不对的,因为cifar_iid和cifar_beta共用之后的代码,这会导致cifar_beta切分后的数据集被再次切分。
希望这能解决你的问题。 @DENGhy123
When I run main_fedIPR.py", it report an error "AttributeError: 'DatasetSplit' object has no attribute 'classes'". Is that missing a function "classes" in the Class 'DatasetSplit'? Hope to hear you. Thank you. @purp1eHaze
The text was updated successfully, but these errors were encountered: