Skip to content

Instantly share code, notes, and snippets.

@ptyshevs
Created September 28, 2019 12:43
Show Gist options
  • Save ptyshevs/3e7ad55995f21f33be957316cb4e741a to your computer and use it in GitHub Desktop.
Save ptyshevs/3e7ad55995f21f33be957316cb4e741a to your computer and use it in GitHub Desktop.
def fitness_similarity(X):
""" Maximize adv_target probability while MSE from adv_sample """
y = model.predict(pt.Tensor(X).unsqueeze(1)).detach().numpy()
y_target = y[:, adv_target]
mse = np.sqrt(np.power(X - adv_sample, 2).mean(axis=1).mean(axis=1))
return y_target - mse
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment