zhmzm / FLAME

22 stars 7 forks source link

客户端抽样的问题 #9

Open DingDante opened 3 days ago

DingDante commented 3 days ago

m = max(int(args.frac * args.num_users), 1) idxs_users = np.random.choice(range(args.num_users), m, replace=False)

    //这里按比例抽取m个客户端索引训练本轮,索引idxs_users 

    if val_acc_list[-1] > backdoor_begin_acc:
        attack_number = int(args.malicious * m)
    else:
        attack_number = 0

    for num_turn, idx in enumerate(idxs_users):
        if attack_number > 0:
            attack = True
        else:
            attack = False

        if attack == True:
            idx = random.randint(0, int(args.num_users * args.malicious))
            // 但实际上这个idx是从所有攻击者中随机选取,但是idx并不一定包含在idxs_users 中呀,  比如idxs_users=[5,6,7,8] ,这里攻击使用的idx可能是0,1,2
zhmzm commented 2 days ago

There are two kinds of settings. The typical one is randomly selecting malicious and benign clients without control. The other one is selecting a fixed number of malicious clients in each round. The code here implements the second one.

DingDante commented 2 days ago

你好,这里的问题我清楚了。最后还是想问个问题,就是上面每轮固定数量的攻击,这种 idx = random.randint(0, int(args.num_users * args.malicious)) ,比如4次攻击分别抽中后门id(0,0,1,2)对于0来说是多执行一次本地训练吗;2)还有我实验中选择的一般是固定数量攻击的话是不重复采样也就是(0,1,2,3)这种攻击方式,感觉比(0,0,1,2)要强,一些文章实验中设置也不同,哪种更普遍呢