Esempio n. 1
0
 def _init_model(self, params):
     super(HeteroSVDppBase, self)._init_model(params)
     self.params = params
     self.transfer_variable = HeteroSVDppTransferVariable()
     secure_aggregate = params.secure_aggregate
     self.aggregator = aggregator.with_role(
         role=self.role,
         transfer_variable=self.transfer_variable,
         enable_secure_aggregate=secure_aggregate)
     self.max_iter = params.max_iter
     self.aggregator_iter = 0
Esempio n. 2
0
    def _init_model(self, param):
        super()._init_model(param)
        self.param = param

        self.transfer_variable = HomoTransferVariable()
        secure_aggregate = param.secure_aggregate
        self.aggregator = aggregator.with_role(role=self.role,
                                               transfer_variable=self.transfer_variable,
                                               enable_secure_aggregate=secure_aggregate)
        self.max_iter = param.max_iter
        self.aggregator_iter = 0
Esempio n. 3
0
 def _init_model(self, params):
     super(HeteroGMFBase, self)._init_model(params)
     self.params = params
     self.transfer_variable = HeteroGMFTransferVariable()
     secure_aggregate = params.secure_aggregate
     if not self.has_registered:
         self.aggregator = aggregator.with_role(
             role=self.role,
             transfer_variable=self.transfer_variable,
             enable_secure_aggregate=secure_aggregate)
         self.has_registered = True
     self.max_iter = params.max_iter
     self.aggregator_iter = 0
Esempio n. 4
0
    def call(cls, role, transfer_variable, ind, *args):
        agg = aggregator.with_role(role,
                                   transfer_variable,
                                   enable_secure_aggregate=True)
        if role == consts.ARBITER:
            agg.aggregate_and_broadcast()
            print(agg.aggregate_loss())
        else:
            # 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()
            aggregated = agg.aggregate_then_get(w, degree=d)

            agg.send_loss(2.0)
            return aggregated, raw, d