Exemplo n.º 1
0
 def send_activations_and_labels_to_server(self, acts, labels, receive_id):
     message = Message(MyMessage.MSG_TYPE_C2S_SEND_ACTS,
                       self.get_sender_id(), receive_id)
     if self.dp_mechanism.dp_type == "LDP":
         labels = self.dp_mechanism.compute_randomized_weights(labels)
     message.add_params(MyMessage.MSG_ARG_KEY_ACTS, (acts, labels))
     self.send_message(message)
 def send_message_init_config(self, receive_id, global_model_params,
                              client_index):
     message = Message(MyMessage.MSG_TYPE_S2C_INIT_CONFIG,
                       self.get_sender_id(), receive_id)
     message.add_params(MyMessage.MSG_ARG_KEY_MODEL_PARAMS,
                        global_model_params)
     message.add_params(MyMessage.MSG_ARG_KEY_CLIENT_INDEX,
                        str(client_index))
     self.send_message(message)
 def send_message_sync_model_to_client(self, receive_id,
                                       global_model_params, client_index):
     logging.info("send_message_sync_model_to_client. receive_id = %d" %
                  receive_id)
     message = Message(MyMessage.MSG_TYPE_S2C_SYNC_MODEL_TO_CLIENT,
                       self.get_sender_id(), receive_id)
     message.add_params(MyMessage.MSG_ARG_KEY_MODEL_PARAMS,
                        global_model_params)
     message.add_params(MyMessage.MSG_ARG_KEY_CLIENT_INDEX,
                        str(client_index))
     self.send_message(message)
Exemplo n.º 4
0
 def send_model_to_server(self, receive_id, weights, local_sample_num):
     message = Message(MyMessage.MSG_TYPE_C2S_SEND_MODEL_TO_SERVER, self.get_sender_id(), receive_id)
     message.add_params(MyMessage.MSG_ARG_KEY_MODEL_PARAMS, weights)
     message.add_params(MyMessage.MSG_ARG_KEY_NUM_SAMPLES, local_sample_num)
     self.send_message(message)
Exemplo n.º 5
0
 def send_grads_to_client(self, receive_id, grads):
     message = Message(MyMessage.MSG_TYPE_S2C_GRADS, self.get_sender_id(),
                       receive_id)
     message.add_params(MyMessage.MSG_ARG_KEY_GRADS, grads)
     self.send_message(message)
Exemplo n.º 6
0
 def send_model_to_server(self, receive_id, client_gradient):
     message = Message(MyMessage.MSG_TYPE_C2S_INFORMATION, self.get_sender_id(), receive_id)
     message.add_params(MyMessage.MSG_ARG_KEY_INFORMATION, client_gradient)
     self.send_message(message)
Exemplo n.º 7
0
 def send_message_to_client(self, receive_id, global_result):
     message = Message(MyMessage.MSG_TYPE_S2C_INFORMATION,
                       self.get_sender_id(), receive_id)
     message.add_params(MyMessage.MSG_ARG_KEY_INFORMATION, global_result)
     self.send_message(message)