我在用TFF做一些实验。在这个例子中,我想根据poisson subsampling在每一次培训中对参与的客户进行抽样,其中每个客户被抽样的概率为p = users_per_round / num_users。
在每一轮中,都会执行poisson subsampling,直到列表sampled_ids中填充了与users_per_round数量相等的唯一ids。
total_rounds = 100
num_users = 500
users_per_round = 150
lambda_value = np.random.rand()
for round_num in range(total_rounds):
sampled_ids = []
while len(sampled_ids) < users_per_round:
subsampling = np.random.poisson(lambda_value, num_users)
whether = subsampling > 1 - users_per_round / num_users
for i in np.arange(num_users):
if whether[i] and len(sampled_ids) < users_per_round and i
not in sampled_ids:
sampled_ids.append(i)
sampled_clients = [train_data.client_ids[i] for i in sampled_ids]
sampled_train_data =
[train_data.create_tf_dataset_for_client(client) for client in
sampled_clients]
server_state, train_metrics = iterative_process.next(server_state,
sampled_train_data)是否有更好的方法来执行poisson subsampling,特别是如果在differentially private FL中应用了次抽样,以便RDP accountant获得准确的隐私分析结果?
除了lambda值之外,设置random值的最佳策略是什么?
发布于 2021-03-08 17:42:07
泊松次抽样是指每个用户都包含在概率q中。如果q很小的话,您从这个过程中得到的每一轮的用户数大约都是泊松分布的。如果您想要这样的示例,即期望users_per_round用户在一轮中运行,您可以执行以下操作:
users_this_round = np.random.poisson(users_per_round)
sampled_ids = np.random.choice(num_users, size=users_this_round, replace=False)如果您想准确地选择users_per_round用户(技术上不是泊松次抽样),您可以这样做:
sampled_ids = np.random.choice(num_users, size=users_per_round, replace=False)https://stackoverflow.com/questions/66451298
复制相似问题