-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgaussian.py
25 lines (20 loc) · 955 Bytes
/
gaussian.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import numpy as np
from global_utils import actor
from attackers.pbases.mpbase import MPBase
from attackers import attacker_registry
from fl.client import Client
@attacker_registry
@actor('attacker', 'model_poisoning', 'non_omniscient')
class Gaussian(MPBase, Client):
"""
[Machine Learning with Adversaries: Byzantine Tolerant Gradient Descent](https://papers.nips.cc/paper_files/paper/2017/hash/f4b9ec30ad9f68f89b29639786cb62ef-Abstract.html) - NeurIPS '17
submit Gaussian noise as the update
"""
def __init__(self, args, worker_id, train_dataset, test_dataset):
Client.__init__(self, args, worker_id, train_dataset, test_dataset)
self.default_attack_params = {'noise_mean': 0, 'noise_std': 1}
self.update_and_set_attr()
def non_omniscient(self):
noise = np.random.normal(
loc=self.noise_mean, scale=self.noise_std, size=self.update.shape).astype(np.float32)
return noise