deel.lip.metrics
This module contains metrics applicable in provable robustness. See https://arxiv.org/abs/2006.06520 and https://arxiv.org/abs/2108.04062 for more information.
BinaryProvableAvgRobustness ¶
BinaryProvableAvgRobustness(
lip_const=1.0,
negative_robustness=False,
reduction=Reduction.AUTO,
name="BinaryProvableAvgRobustness",
)
Bases: Loss
Compute the average provable robustness radius on the dataset.
\(\mathcal{M}_f(x)\) is a term that: is positive when x is correctly classified and negative otherwise. In both case the value give the robustness radius around x.
In the binary classification setup we have:
Where \(D\) is the dataset, \(l\) is the correct label for x and \(L_f\) is the lipschitz constant of the network..
When negative_robustness
is set to True
misclassified elements count as
negative robustness (\(\phi\) act as identity function), when set to
False
,
misclassified elements yield a robustness radius of 0 ( \(\phi(x)=relu(
x)\) ). The elements are not ignored when computing the mean in both cases.
This metric works for labels both in {1,0} and {1,-1}.
PARAMETER | DESCRIPTION |
---|---|
lip_const |
lipschitz constant of the network
TYPE:
|
reduction |
the recution method when training in a multi-gpu / TPU system
DEFAULT:
|
name |
metrics name.
TYPE:
|
Source code in deel/lip/metrics.py
238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 |
|
BinaryProvableRobustAccuracy ¶
BinaryProvableRobustAccuracy(
epsilon=36 / 255,
lip_const=1.0,
reduction=Reduction.AUTO,
name="BinaryProvableRobustAccuracy",
)
Bases: Loss
The accuracy that can be proved at a given epsilon.
PARAMETER | DESCRIPTION |
---|---|
epsilon |
the metric will return the guaranteed accuracy for the radius epsilon.
TYPE:
|
lip_const |
lipschitz constant of the network
TYPE:
|
reduction |
the recution method when training in a multi-gpu / TPU system
DEFAULT:
|
name |
metrics name.
TYPE:
|
Source code in deel/lip/metrics.py
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
|
CategoricalProvableAvgRobustness ¶
CategoricalProvableAvgRobustness(
lip_const=1.0,
disjoint_neurons=True,
negative_robustness=False,
reduction=Reduction.AUTO,
name="CategoricalProvableAvgRobustness",
)
Bases: Loss
Compute the average provable robustness radius on the dataset.
\(\mathcal{M}_f(x)\) is a term that: is positive when x is correctly classified and negative otherwise. In both case the value give the robustness radius around x.
In the multiclass setup we have:
Where \(D\) is the dataset, \(l\) is the correct label for x and
\(L_f\) is the lipschitz constant of the network (\(L = 2 \times
\text{lip_const}\) when disjoint_neurons=True
, \(L = \sqrt{2} \times
\text{lip_const}\) otherwise).
When negative_robustness
is set to True
misclassified elements count as
negative robustness (\(\phi\) act as identity function), when set to
False
,
misclassified elements yield a robustness radius of 0 ( \(\phi(x)=relu(
x)\) ). The elements are not ignored when computing the mean in both cases.
This metric works for labels both in {1,0} and {1,-1}.
PARAMETER | DESCRIPTION |
---|---|
lip_const |
lipschitz constant of the network
TYPE:
|
disjoint_neurons |
must be set to True is your model ends with a
FrobeniusDense layer with
TYPE:
|
reduction |
the recution method when training in a multi-gpu / TPU system
DEFAULT:
|
name |
metrics name.
TYPE:
|
Source code in deel/lip/metrics.py
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 |
|
CategoricalProvableRobustAccuracy ¶
CategoricalProvableRobustAccuracy(
epsilon=36 / 255,
lip_const=1.0,
disjoint_neurons=True,
reduction=Reduction.AUTO,
name="CategoricalProvableRobustAccuracy",
)
Bases: Loss
The accuracy that can be proved at a given epsilon.
PARAMETER | DESCRIPTION |
---|---|
epsilon |
the metric will return the guaranteed accuracy for the radius epsilon.
TYPE:
|
lip_const |
lipschitz constant of the network
TYPE:
|
disjoint_neurons |
must be set to True if your model ends with a
FrobeniusDense layer with
TYPE:
|
reduction |
the recution method when training in a multi-gpu / TPU system
DEFAULT:
|
name |
metrics name.
TYPE:
|
Source code in deel/lip/metrics.py
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
|