Esempio 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)
Esempio n. 2
0
 def send_message(self, message):
     msg = Message()
     msg.add(Message.MSG_ARG_KEY_TYPE, message.get_type())
     msg.add(Message.MSG_ARG_KEY_SENDER, message.get_sender_id())
     msg.add(Message.MSG_ARG_KEY_RECEIVER, message.get_receiver_id())
     for key, value in message.get_params().items():
         # logging.info("%s == %s" % (key, value))
         msg.add(key, value)
     self.com_manager.send_message(msg)
Esempio n. 3
0
 def run(self):
     logging.debug("Starting Thread:" + self.name + ". Process ID = " + str(self.rank))
     while True:
         try:
             msg_str = self.comm.recv()
             msg = Message()
             msg.init(msg_str)
             self.q.put(msg)
         except Exception:
             traceback.print_exc()
 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)
Esempio n. 6
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)
Esempio n. 7
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)
Esempio n. 8
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)
Esempio n. 9
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)
Esempio n. 10
0
 def send_message_init_config(self, receive_id):
     message = Message(MyMessage.MSG_TYPE_S2C_INIT_CONFIG,
                       self.get_sender_id(), receive_id)
     self.send_message(message)
Esempio n. 11
0
 def send_finish_to_server(self, receive_id):
     message = Message(MyMessage.MSG_TYPE_C2S_PROTOCOL_FINISHED,
                       self.get_sender_id(), receive_id)
     self.send_message(message)
Esempio n. 12
0
 def send_validation_over_to_server(self, receive_id):
     message = Message(MyMessage.MSG_TYPE_C2S_VALIDATION_OVER,
                       self.get_sender_id(), receive_id)
     self.send_message(message)
Esempio n. 13
0
 def send_semaphore_to_client(self, receive_id):
     message = Message(MyMessage.MSG_TYPE_C2C_SEMAPHORE,
                       self.get_sender_id(), receive_id)
     self.send_message(message)