Aggregate collected weights to update server weight. Args: weights (Dict[str, List[tensor.Tensor]]): The collected weights. Returns: Dict[str, tensor.Tensor]: Updated weight stored in server.
(self, weights: Dict[str, List[tensor.Tensor]])
| 103 | self.sock.close() |
| 104 | |
| 105 | def aggregate(self, weights: Dict[str, List[tensor.Tensor]]) -> Dict[str, tensor.Tensor]: |
| 106 | """Aggregate collected weights to update server weight. |
| 107 | |
| 108 | Args: |
| 109 | weights (Dict[str, List[tensor.Tensor]]): The collected weights. |
| 110 | |
| 111 | Returns: |
| 112 | Dict[str, tensor.Tensor]: Updated weight stored in server. |
| 113 | """ |
| 114 | for k, v in weights.items(): |
| 115 | self.weights[k] = sum(v) / self.num_clients |
| 116 | return self.weights |
| 117 | |
| 118 | def pull(self) -> None: |
| 119 | """Server pull weights from clients. |