declearn.aggregator.AveragingAggregator
Bases: Aggregator[ModelUpdates]
Average-based-aggregation Aggregator subclass.
This class implements local updates' averaging, with optional client-based and/or number-of-training-steps-based weighting.
It may therefore be used to implement FedAvg and derivatives that use simple weighting schemes.
Source code in declearn/aggregator/_avg.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
|
__init__(steps_weighted=True, client_weights=None)
Instantiate an averaging aggregator.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
steps_weighted |
bool
|
Whether to conduct a weighted averaging of local model updates based on local numbers of training steps. |
True
|
client_weights |
Optional[Dict[str, float]]
|
DEPRECATED - this argument no longer affects computations, save when using the deprecated 'aggregate' method. Optional dict of client-wise base weights to use. If None, homogeneous base weights are used. |
None
|
Notes
- One may specify
client_weights
and usesteps_weighted=True
. In that case, the product of the client's base weight and their number of training steps taken will be used (and unit-normed). - One may use incomplete
client_weights
. In that case, unknown- clients' base weights will be set to 1.
Source code in declearn/aggregator/_avg.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
|
compute_client_weights(updates, n_steps)
Compute weights to use when averaging a given set of updates.
This method is DEPRECATED as of DecLearn v2.4. It will be removed in DecLearn 2.6 and/or 3.0.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
updates |
Dict[str, Vector]
|
Client-wise updates, as a dictionary with clients' names as string keys and updates as Vector values. |
required |
n_steps |
Dict[str, int]
|
Client-wise number of local training steps performed during the training round having produced the updates. |
required |
Returns:
Name | Type | Description |
---|---|---|
weights |
dict[str, float]
|
Client-wise updates-averaging weights, suited to the input parameters and normalized so that they sum to 1. |
Source code in declearn/aggregator/_avg.py
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
|