Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

计算L范数的相对值 #33

Open
zheng547 opened this issue Aug 30, 2021 · 0 comments
Open

计算L范数的相对值 #33

zheng547 opened this issue Aug 30, 2021 · 0 comments

Comments

@zheng547
Copy link

https://github.com/duoergun0729/adversarial_examples/blob/master/code/tools.py
#计算相对量
#l0 = int(99len(np.where(np.abs(img[0] - img_adv[0])>0.5)[0]) / size ) + 1
l0=int(_l0
99/size)+1
l1 = int(99np.sum(np.abs(img[0] - img_adv[0])) / np.sum(np.abs(img[0]))) + 1
#l2 = int(99
np.linalg.norm(img[0] - img_adv[0]) / np.linalg.norm(img[0])) + 1
l2=int(99*_l2 / np.linalg.norm(img[0])) + 1
#linf = int(99np.max(np.abs(img[0] - img_adv[0])) / 255) + 1
linf = int(99
_linf / 255) + 1
print('Noise L_0 norm: {} {}%'.format(_l0,l0) )
print('Noise L_2 norm: {} {}%'.format(_l2,l2) )
print('Noise L_inf norm: {} {}%'.format(_linf,linf) )

为什么要乘99,以及为什么要加1?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant