I am using FGSM attack using cleverhans. My code is as follows:
logits_model = tf.keras.Model(model_1.input, model_1.layers[-1].output)
target_label = tf.one_hot(3, depth=19)
adv_sample = fast_gradient_method.fast_gradient_method(logits_model, x, eps = 0.9, norm = 2, y = target_label, targeted = True)
I am getting this error
loss = loss_fn(labels=y, logits=model_fn(x))
ValueError: `labels.shape` must equal `logits.shape` except for the last dimension. Received: labels.shape=(19,) and logits.shape=(1, 19)
I reshaped my targeted_label using target_label = np.reshape(target_label, (1, 19)), got this error
ValueError: `labels.shape.rank` must equal `logits.shape.rank - 1`. Received: labels.shape=(1, 19) of rank 2 and logits.shape=(1, 19) of rank 2
I reshaped my targeted_label using
target_label = np.reshape(target_label, (1, 19)), got this error
ValueError: `labels.shape.rank` must equal `logits.shape.rank - 1`. Received: labels.shape=(1, 19) of rank 2 and logits.shape=(1, 19) of rank 2