예제 #1
0
 def __init__(
         self,
         trans_var: SecureAggregatorTransVar = SecureAggregatorTransVar(),
         enable_secure_aggregate=True):
     self.enable_secure_aggregate = enable_secure_aggregate
     self._aggregator = aggregator.Client(
         trans_var=trans_var.aggregator_trans_var)
     if enable_secure_aggregate:
         self._random_padding_cipher: PadsCipher = \
             random_padding_cipher.Client(trans_var=trans_var.random_padding_cipher_trans_var).create_cipher()
예제 #2
0
    def __init__(self, max_num_aggregation, aggregate_every_n_epoch, name="default"):
        super(PyTorchSAClientContext, self).__init__(
            max_num_aggregation=max_num_aggregation, name=name
        )
        self.transfer_variable = SecureAggregatorTransVar()
        self.aggregator = aggregator.Client(self.transfer_variable.aggregator_trans_var)
        self.random_padding_cipher = random_padding_cipher.Client(
            self.transfer_variable.random_padding_cipher_trans_var
        )
        self.aggregate_every_n_epoch = aggregate_every_n_epoch
        self._params: list = None

        self._should_stop = False
        self.loss_summary = []
예제 #3
0
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()