Skip to content

Commit c94e10b

Browse files
committed
final fixes
1 parent 2b910e8 commit c94e10b

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

metainfo/mi_defense_parameters.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"EmptyMIDefender": {
33
},
44
"NoiseMIDefender": {
5-
"noise_type": ["Noise type", "str", "reverse_sigmoid", ["reverse_sigmoid", "random", "none"], "Type of noise to apply"],
5+
"noise_type": ["Noise type", "string", "reverse_sigmoid", ["reverse_sigmoid", "random", "none"], "Type of noise to apply"],
66
"beta": ["Beta", "float", 0.5, {"min": 0, "max": 10, "step": 0.1}, "Beta for reverse sigmoid"],
77
"gamma": ["Gamma", "float", 1.0, {"min": 0, "max": 10, "step": 0.1}, "Gamma for reverse sigmoid"],
88
"noise_scale": ["Noise scale", "float", 0.1, {"min": 0, "max": 1, "step": 0.01}, "Uniform noise magnitude"],

src/attacks/evasion_attacks.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,15 @@ def __init__(
7979
self.attack_diff = GraphModificationArtifact()
8080
self.attack_res_misha = None
8181

82+
@staticmethod
83+
def get_attack_loss(model_manager):
84+
"""
85+
Returns a loss function that computes -loss_fn(pred, target). Lower loss value means better attack.
86+
"""
87+
def attack_loss(output, target):
88+
return -model_manager.loss_function(output, target)
89+
return attack_loss
90+
8291
def attack(
8392
self,
8493
model_manager: Type,

web_interface/back_front/attack_defense_blocks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ def do(
219219
metrics_values = res
220220

221221
# Apply MI attack and get metrics
222-
if self.ad_configs["AD-ea"] is not None:
222+
if self.ad_configs["AD-ma"] is not None:
223223
import numpy as np
224224
assert not self.gen_dataset.is_multi()
225225
target_list = np.random.choice(

0 commit comments

Comments
 (0)