def adv_acc(y, _): # Generate adversarial examples x_adv = fgsm(model, y, eps=eps, clip_min=clip_min, clip_max=clip_max) # Consider the attack to be constant x_adv = K.stop_gradient(x_adv) # Accuracy on the adversarial examples preds_age, preds_race, preds_gender = model(x_adv) return categorical_accuracy(y, preds_race)
def adv_acc(y, _): # Generate adversarial examples y_gender = tf.get_default_graph().get_tensor_by_name("gender_target:0") x_adv = fgsm(model, y_gender, eps=eps, clip_min=clip_min, clip_max=clip_max) # Consider the attack to be constant x_adv = K.stop_gradient(x_adv) # Accuracy on the adversarial examples _, preds_age = model(x_adv) return categorical_accuracy(y, preds_age)
def adv_acc(y, _): # Generate adversarial examples #y_race = tf.get_default_graph().get_tensor_by_name("race_target:0") x_adv = fgsm(model, y, eps=eps, clip_min=clip_min, clip_max=clip_max) # Consider the attack to be constant x_adv = K.stop_gradient(x_adv) # Accuracy on the adversarial examples preds_age, preds_race, preds_gender = model(x_adv) return mae(y, preds_age)