Skip to content

TF2: CarliniWagnerL2 fails if argument y is provided and batch size is unequal to number of samples #1241

@thijs-vanweezel

Description

@thijs-vanweezel

The issue tracker should only be used to report bugs or feature requests. If you are looking for support from other library users, please ask a question on StackOverflow.

Describe the bug
If an argument for parameter y is provided in the function carlini_wagner_l2, the error below is raised, and the only way to avoid this is to set argument batch_size equal to the number of samples in y.
CarliniWagnerL2Exception: x and y do not have the same shape!

To Reproduce

import tensorflow as tf
from cleverhans.tf2.attacks.carlini_wagner_l2 import carlini_wagner_l2

(x, y), _ = tf.keras.datasets.cifar10.load_data()
x = tf.image.convert_image_dtype(y, dtype=tf.float32)

# <load model here>

x_adv = carlini_wagner_l2(classifier, x=x[:8], y=y[:8], max_iterations=10, batch_size=4) # arguments chosen for time concerns

Expected behavior
Just like x, the argument y should be split into batches.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions