Skip to content

Commit f6e7c2c

Browse files
committed
Adding fix for loss turning to nan
Signed-off-by: Shriti Priya <[email protected]>
1 parent dc29bbc commit f6e7c2c

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

art/attacks/poisoning/sleeper_agent_attack.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,11 @@ def poison( # type: ignore
229229
best_B = B_ # pylint: disable=C0103
230230
best_x_poisoned = x_poisoned
231231
best_indices_poison = self.indices_poison
232+
if best_B == np.finfo(np.float32).max:
233+
logger.warning("Attack unsuccessful: all loss values were non-finite. Defaulting to final trial.")
234+
best_B = B_ # pylint: disable=C0103
235+
best_x_poisoned = x_poisoned
236+
best_indices_poison = self.indices_poison
232237

233238
# Apply De-Normalization
234239
if isinstance(

0 commit comments

Comments
 (0)