Hyperparticle / one-pixel-attack-keras

Keras implementation of "One pixel attack for fooling deep neural networks" using differential evolution on Cifar10 and ImageNet
https://arxiv.org/abs/1710.08864
MIT License
1.21k stars 213 forks source link

how to fix RuntimeWarning: divide by zero encountered in double_scalars #21

Closed LunarMaterial closed 4 years ago

LunarMaterial commented 4 years ago

using model lenet , when attacking it warns that "RuntimeWarning: divide by zero encountered in double_scalars" convergence=self.tol / convergence) is True): it means covergence is zero? i dont know how to fix this please help me! the error is appears in differential _evolution.py :585

Hyperparticle commented 4 years ago

That's quite odd, not sure why it would be zero. You can try to fix it by changing the line to convergence=self.tol / (convergence + 1e-6) so that the denominator is always nonzero.