Python code to find a universal perturbation [1], using the TensorFlow library.
To get started, you can run the demo code to apply a pre-computed universal perturbation for Inception on the image of your choice
python demo_inception.py -i data/test_img.png
This will download the pre-trained model, and show the image without and with universal perturbation with the estimated labels.
In this example, the pre-computed universal perturbation in data/universal.npy is used.
To compute a universal perturbation for your model, please follow the same struture as in demo_inception.py.
In particular, you should use the universal_perturbation function (see universal_pert.py for details), with the set of training images
used to compute the perturbation, as well as the feedforward and gradient functions.
[1] S. Moosavi-Dezfooli*, A. Fawzi*, O. Fawzi, P. Frossard: Universal adversarial perturbations, CVPR 2017.