def __init__( self, trans_var: SecureAggregatorTransVar = SecureAggregatorTransVar(), enable_secure_aggregate=True): self._aggregator = aggregator.Server( trans_var=trans_var.aggregator_trans_var) self.enable_secure_aggregate = enable_secure_aggregate if enable_secure_aggregate: random_padding_cipher.Server(trans_var=trans_var.random_padding_cipher_trans_var) \ .exchange_secret_keys()
def __init__(self, max_num_aggregation, eps=0.0, name="default"): super(PyTorchSAServerContext, self).__init__(max_num_aggregation=max_num_aggregation, name=name) self.transfer_variable = SecureAggregatorTransVar() self.aggregator = aggregator.Server( self.transfer_variable.aggregator_trans_var) self.random_padding_cipher = random_padding_cipher.Server( self.transfer_variable.random_padding_cipher_trans_var) self._eps = eps self._loss = math.inf
def aggregator_call(job_id, role, ind, *args): server_model = args[0][0] client_models = args[0][1:] if role == consts.ARBITER: agg = aggregator.Server() models = agg.get_models() agg.send_aggregated_model(server_model) return models else: agg = aggregator.Client() if role == consts.GUEST: agg.send_model(client_models[0]) else: agg.send_model(client_models[ind + 1]) return agg.get_aggregated_model()