cleverhans-lab / cleverhans

An adversarial example library for constructing attacks, building defenses, and benchmarking both
MIT License
6.15k stars 1.39k forks source link

'get_shape' Attribute #1235

Open amissafari opened 1 year ago

amissafari commented 1 year ago

Describe the bug when I use optimize_linear function from utils.py. I get the following error: 'numpy.ndarray' object has no attribute 'get_shape'

When I check the code there was no function definition for attribute get_shape.

To Reproduce Steps to reproduce the behavior:

  1. Go to utils.py
  2. Check def optimize_linear(grad, eps, norm=np.inf) at line 198
  3. I used optimize_linear in the following code: def F_FGM (dncnn_model, x,r,c,val, eps, norm, ): grad = F_Gradient (dncnn_model,x,r,c,val,0.0001) optimal_perturbation = optimize_linear(grad, eps, norm) %% Add perturbation to original example to obtain adversarial example adv_x = x + optimal_perturbation.numpy() return adv_x z1 = z + np.linalg.norm(z)F_FGM(dncnn_model,z,r,c,val_label[i,:,:],np.linalg.norm(x)/SS,2)/(SSnp.linalg.norm(F_FGM(dncnn_model,z,r,c,val_label[i,:,:],np.linalg.norm(x)/SS,2)))

Note: The dncnn is my CNN network.

Expected behavior Code runs without issue and create a perturbed signal

System configuration