Beispiel #1
0
    def __init__(self, trans_var):
        super().__init__(trans_var=trans_var)
        self.model = None

        self.aggregator = secure_mean_aggregator.Server(self.transfer_variable.secure_aggregator_trans_var)
        self.loss_scatter = loss_scatter.Server(self.transfer_variable.loss_scatter_trans_var)
        self.has_converged = has_converged.Server(self.transfer_variable.has_converged_trans_var)

        self._summary = dict(loss_history=[], is_converged=False)
Beispiel #2
0
def server_init_model(self, param):
    self.aggregate_iteration_num = 0
    self.aggregator = secure_mean_aggregator.Server(
        self.transfer_variable.secure_aggregator_trans_var)
    self.loss_scatter = loss_scatter.Server(
        self.transfer_variable.loss_scatter_trans_var)
    self.has_converged = has_converged.Server(
        self.transfer_variable.has_converged_trans_var)

    self._summary = dict(loss_history=[], is_converged=False)

    self.param = param
    self.enable_secure_aggregate = param.secure_aggregate
    self.max_aggregate_iteration_num = param.max_iter
    early_stop = self.model_param.early_stop
    self.converge_func = converge_func_factory(early_stop.converge_func,
                                               early_stop.eps).is_converge
    self.loss_consumed = early_stop.converge_func != "weight_diff"
Beispiel #3
0
def secure_aggregator_call(job_id, role, ind, *args):
    if role == consts.ARBITER:
        agg = secure_mean_aggregator.Server()
        model = agg.weighted_mean_model()
        agg.send_aggregated_model(model)
    else:
        agg = secure_mean_aggregator.Client()
        # disorder dit
        order = list(range(5))
        np.random.seed(random.SystemRandom().randint(1, 100))
        np.random.shuffle(order)
        raw = {k: np.random.rand(10, 10) for k in order}

        w = OrderDictWeights(copy.deepcopy(raw))
        d = random.random()
        agg.send_weighted_model(w, weight=d)
        aggregated = agg.get_aggregated_model()
        return aggregated, raw, d
Beispiel #4
0
 def __init__(self):
     self.aggregator = secure_mean_aggregator.Server(
         enable_secure_aggregate=True)
     self.suffix = tuple()