Module mimir.attacks.blackbox_attacks
+Module mimir.attacks.all_attacks
Enum class for attacks. Also contains the base attack class.
@@ -36,22 +36,24 @@Module mimir.attacks.blackbox_attacks
# Attack definitions
-class BlackBoxAttacks(str, Enum):
+class AllAttacks(str, Enum):
LOSS = "loss" # Done
REFERENCE_BASED = "ref" # Done
ZLIB = "zlib" # Done
MIN_K = "min_k" # Done
NEIGHBOR = "ne" # Done
+ GRADNORM = "gradnorm" # Done
# QUANTILE = "quantile" # Uncomment when tested implementation is available
# Base attack class
class Attack:
- def __init__(self, config, target_model: Model, ref_model: Model = None):
+ def __init__(self, config, target_model: Model, ref_model: Model = None, is_blackbox: bool = True):
self.config = config
self.target_model = target_model
self.ref_model = ref_model
self.is_loaded = False
+ self.is_blackbox = is_blackbox
def load(self):
"""
@@ -105,9 +107,61 @@ Module mimir.attacks.blackbox_attacks
Classes
-
-
+
++class AllAttacks +(value, names=None, *, module=None, qualname=None, type=None, start=1) +
- +
++An enumeration.
+++Expand source code +
+
+class AllAttacks(str, Enum): + LOSS = "loss" # Done + REFERENCE_BASED = "ref" # Done + ZLIB = "zlib" # Done + MIN_K = "min_k" # Done + NEIGHBOR = "ne" # Done + GRADNORM = "gradnorm" # Done + # QUANTILE = "quantile" # Uncomment when tested implementation is available
Ancestors
+-
+
- builtins.str +
- enum.Enum +
Class variables
+-
+
var GRADNORM
+- + + +
var LOSS
+- + + +
var MIN_K
+- + + +
var NEIGHBOR
+- + + +
var REFERENCE_BASED
+- + + +
var ZLIB
+- + + +
class Attack -(config, target_model: Model, ref_model: Model = None) +(config, target_model: Model, ref_model: Model = None, is_blackbox: bool = True)
- @@ -116,11 +170,12 @@
-Classes
Expand source codeclass Attack: - def __init__(self, config, target_model: Model, ref_model: Model = None): + def __init__(self, config, target_model: Model, ref_model: Model = None, is_blackbox: bool = True): self.config = config self.target_model = target_model self.ref_model = ref_model self.is_loaded = False + self.is_blackbox = is_blackbox def load(self): """ @@ -166,6 +221,7 @@
Classes
Subclasses
-
+
- GradNormAttack
- LOSSAttack
- MinKProbAttack
- NeighborhoodAttack @@ -175,7 +231,7 @@
Subclasses
Methods
-
-
+
def attack(self, document, probs, **kwargs)
- @@ -208,7 +264,7 @@
Methods
return score
+
-def load(self)
- @@ -226,7 +282,7 @@
Methods
self.is_loaded = True+
def unload(self)
- @@ -243,53 +299,6 @@
Methods
-class BlackBoxAttacks
-(value, names=None, *, module=None, qualname=None, type=None, start=1)
-
An enumeration.
-Expand source code -
-class BlackBoxAttacks(str, Enum):
- LOSS = "loss" # Done
- REFERENCE_BASED = "ref" # Done
- ZLIB = "zlib" # Done
- MIN_K = "min_k" # Done
- NEIGHBOR = "ne" # Done
- # QUANTILE = "quantile" # Uncomment when tested implementation is available
-Ancestors
--
-
- builtins.str -
- enum.Enum -
Class variables
--
-
var LOSS
-- - - -
var MIN_K
-- - - -
var NEIGHBOR
-- - - -
var REFERENCE_BASED
-- - - -
var ZLIB
-- - - -