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

projected_gradient_descent() gives an error #1204

Open
ananthceh19 opened this issue Mar 26, 2021 · 1 comment
Open

projected_gradient_descent() gives an error #1204

ananthceh19 opened this issue Mar 26, 2021 · 1 comment

Comments

@ananthceh19
Copy link

ananthceh19 commented Mar 26, 2021

Describe the bug
projected_gradient_descent() gives an error: "TypeError: Cannot convert 0.3 to EagerTensor of dtype uint8" when run on Google Colab.

To Reproduce
Steps to reproduce the behavior:
While running the following code (present in cleverhans/cleverhans/tutorials/tf2/mnist_tutorial.py:
for epoch in range(FLAGS.nb_epochs):
# keras like display of progress
progress_bar_train = tf.keras.utils.Progbar(60000)
for (x, y) in data.train:
if FLAGS.adv_train:
# Replace clean example with adversarial example for adversarial training
print('x is ',x.shape)
print('y is ',y.shape)
print('Calling PGD')
#print(eps)
#import pdb; pdb.set_trace()
x = projected_gradient_descent(model, x, 0.3, 0.01, 40, np.inf)
#print(x)
train_step(x, y)
progress_bar_train.add(x.shape[0], values=[("loss", train_loss.result())])
........
projected_gradient_descent() gives the following error:

TypeError Traceback (most recent call last)
in ()
36 #print(eps)
37 #import pdb; pdb.set_trace()
---> 38 x = projected_gradient_descent(model, x, 0.3, 0.01, 40, np.inf)
39 train_step(x, y)
40 progress_bar_train.add(x.shape[0], values=[("loss", train_loss.result())])

4 frames
/usr/local/lib/python3.7/dist-packages/tensorflow/python/ops/gen_math_ops.py in minimum(x, y, name)
5927 try:
5928 _result = pywrap_tfe.TFE_Py_FastPathExecute(
-> 5929 _ctx, "Minimum", name, x, y)
5930 return _result
5931 except _core._NotOkStatusException as e:

TypeError: Cannot convert 0.3 to EagerTensor of dtype uint8

Expected behavior
A clear and concise description of what you expected to happen.

eps cannot be of type uint8 and projected_gradient_descent method is not expected to give this error.

Screenshots
If applicable, add screenshots to help explain your problem.

System configuration

@tejuafonja
Copy link
Collaborator

Hi, @ananthceh19 thanks for reporting this. Which version of cleverhans are you using, please?

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

2 participants