Skip to content

Commit 0dac208

Browse files
arjungtensorflow-copybara
authored andcommitted
Updates documentation for AdvRegConfig.feature_mask.
PiperOrigin-RevId: 305731974
1 parent a8f2e90 commit 0dac208

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

neural_structured_learning/configs/configs.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,13 @@ class AdvNeighborConfig(object):
3838
"""Contains configuration for generating adversarial neighbors.
3939
4040
Attributes:
41-
feature_mask: mask (w/ 0-1 values) applied on the perturbations. The
42-
dimensions with zero value won't be perturbed. The shape should be the
43-
same as (or broadcastable to) input features. If the input features are in
44-
a collection (e.g. list or dictionary), this field should also be a
45-
collection of the same structure. If set to `None`, no feature mask will
46-
be applied.
41+
feature_mask: mask w/ values in `[0, 1]` applied on the gradient. Its shape
42+
should be the same as (or broadcastable to) that of the input features.
43+
If the input features are in a collection (e.g. list or dictionary), this
44+
field should also be a collection of the same structure. Input features
45+
corresponding to mask values of 0.0 are *not* perturbed. Setting this
46+
field to `None` is equivalent to setting a mask value of 1.0 for all input
47+
features.
4748
adv_step_size: step size to find the adversarial sample. Default set to
4849
0.001.
4950
adv_grad_norm: type of tensor norm to normalize the gradient. Input will be
@@ -90,12 +91,13 @@ def make_adv_reg_config(
9091
9192
Args:
9293
multiplier: multiplier to adversarial regularization loss. Defaults to 0.2.
93-
feature_mask: mask (w/ values of 0.0 or 1.0) applied on the gradient. Its
94-
shape should be the same as (or broadcastable to) the input features:
95-
input features corresponding to mask values of 0.0 are *not* be perturbed,
96-
while those corresponding to mask values of 1.0 are considered
97-
perturbable. If set to `None`, all input features are considered
98-
perturbable.
94+
feature_mask: mask w/ values in `[0, 1]` applied on the gradient. Its shape
95+
should be the same as (or broadcastable to) that of the input features.
96+
If the input features are in a collection (e.g. list or dictionary), this
97+
field should also be a collection of the same structure. Input features
98+
corresponding to mask values of 0.0 are *not* perturbed. Setting this
99+
field to `None` is equivalent to setting a mask value of 1.0 for all input
100+
features.
99101
adv_step_size: step size to find the adversarial sample. Defaults to 0.001.
100102
adv_grad_norm: type of tensor norm to normalize the gradient. Input will be
101103
converted to `NormType` when applicable (e.g., a value of 'l2' will be

0 commit comments

Comments
 (0)