Skip to main content
. Author manuscript; available in PMC: 2021 Feb 28.
Published in final edited form as: Neurocomputing (Amst). 2019 Oct 31;379:370–378. doi: 10.1016/j.neucom.2019.10.085
Algorithm 2 Single Target l2 Attack
1input:imagex0,predictorF,L2distanceϵ,numberofiterationsN,numberofiterationsofbinarysearchm2output:adversarialperturbationΔx3initializexx,cc0,i04ω0tanh1(2x1)5whilei<m6flagFalse7optimizeroptimizer.minimize(cF(12(tanh(ω0+Δω)+1))+tanh(ω0+Δω)tanh(ω0)2)8whilej<N:9Δωoptimizer.run_one_step10Δx12(tanh(ω0+Δω)tanh(ω0))11ifΔx2<ϵ:12flagTrue13ifF(x+Δx)>F(x):14xx+Δx15jj+116ifflag:17increasec18else19decreasec20ii+121Δxxx0