viceroy

git clone git://git.codymlewis.com/viceroy.git
Log | Files | Refs | README

commit 7456262f042b08756278462685556c844f5fc6cc
parent c2d614a43c4489ce9f20bdf81e0ba314c032851b
Author: Cody Lewis <cody@codymlewis.com>
Date:   Thu, 21 Jan 2021 14:07:12 +1100

Added reputation mechanism to mitigate on-off

Diffstat:
Moptions.json | 11++++++-----
Mserver/global_model.py | 7+++++--
2 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/options.json b/options.json @@ -1,13 +1,13 @@ { - "dataset": "vggface", + "dataset": "mnist", "num_sims": 5, "server_epochs": 3000, "user_epochs": 1, "users": 10, "model_params": { - "architecture": "squeeze", + "architecture": "softmax", "device": "cuda:0", - "batch_size": 196, + "batch_size": 512, "params_mul": 10, "learning_rate": [0.01], "lr_changes": [] @@ -15,7 +15,8 @@ "fit_fun": "foolsgold", "params": { "kappa": 2, - "importance": false + "importance": false, + "reputation": true }, "adversaries": { "percent_adv": 0.5, @@ -24,7 +25,7 @@ "to": 0, "scale_up": false, "toggle_times": null, - "delay": null, + "delay": 1000, "beta": 0.1, "gamma": 0.7, "optimized": true diff --git a/server/global_model.py b/server/global_model.py @@ -79,12 +79,16 @@ def foolsgold(net, grads, params): ) v = torch.tensor([0 for _ in range(num_clients)], dtype=torch.float32) alpha = torch.tensor([0 for _ in range(num_clients)], dtype=torch.float32) + beta = torch.tensor([1 for _ in range(num_clients)], dtype=torch.float32) if len(net.histories) < num_clients: while len(net.histories) < num_clients: net.histories[len(net.histories)] = flat_grads[len(net.histories)] else: for i in range(num_clients): + if params['reputation']: + beta[i] = torch.cosine_similarity(net.histories[i], flat_grads[i], dim=0) net.histories[i] += flat_grads[i] + beta = 2 * beta - 1 if params['importance']: feature_importance = find_feature_importance(net) else: @@ -109,14 +113,13 @@ def foolsgold(net, grads, params): torch.log(alpha[ids] / (1 - alpha[ids])) + 0.5) alpha[alpha > 1] = 1 alpha[alpha < 0] = 0 - # alpha_sum = alpha.sum() alpha = alpha / alpha.sum() if net.net is not None: for k, p in enumerate(net.net.parameters()): for i in range(num_clients): p.data.add_( - # (alpha[i] / alpha_sum) * alpha[i] * + beta[i] * grads[i]['params'][k] ) return alpha