MCPcopy Create free account
hub / github.com/apache/singa / aggregate

Method aggregate

examples/hfl/src/server.py:105–116  ·  view source on GitHub ↗

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]])

Source from the content-addressed store, hash-verified

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.

Callers 1

pullMethod · 0.95

Calls 1

sumFunction · 0.50

Tested by

no test coverage detected