Skip to content

Commit

Permalink
Update SNNL_regularized_train.py
Browse files Browse the repository at this point in the history
  • Loading branch information
npapernot authored Feb 19, 2019
1 parent 14a307c commit 2c692f0
Showing 1 changed file with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,12 @@ def imscatter(points, images, ax=None, zoom=1, cmap="hot"):
ax.get_yaxis().set_ticks([])
return artists

adversarial_gradients = tf.sign(
tf.gradients(cross_entropy_loss.fprop(x, y), x))
adv_gradients_ = sess.run(adversarial_gradients, feed_dict={
x: x_test[:batch_size], y: y_test[:batch_size]})
adv_gradients_ = np.reshape(adv_gradients_, (batch_size, 28*28))
adv_grads = tf.sign(tf.gradients(cross_entropy_loss.fprop(x, y), x))
feed_dict = {x: x_test[:batch_size], y: y_test[:batch_size]}
adv_grads_val = sess.run(adv_grads, feed_dict=feed_dict)
adv_grads_val = np.reshape(adv_grads_val, (batch_size, img_rows * img_cols))

X_embedded = TSNE(n_components=2, verbose=0).fit_transform(adv_gradients_)
X_embedded = TSNE(n_components=2, verbose=0).fit_transform(adv_grads_val)
plt.figure(num=None, figsize=(50, 50), dpi=40, facecolor='w', edgecolor='k')
plt.title("TSNE of Sign of Adv Gradients, SNNLCrossEntropy Model, factor:" +
str(FLAGS.SNNL_factor), fontsize=42)
Expand Down

0 comments on commit 2c692f0

Please sign in to comment.