ebm_sandbox.py [485:499]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        print("Constructed loop {} of pgd attack".format(i))
        X_init = X
        if i == 0:
            X = X + tf.to_float(tf.random_uniform(tf.shape(X), minval=-8, maxval=9, dtype=tf.int32)) / 255.

        logit = compute_logit(X)
        loss = tf.nn.softmax_cross_entropy_with_logits_v2(labels=Y_GT, logits=logit)

        x_grad = tf.sign(tf.gradients(loss, [X])[0]) / 255.
        X = X + 2 * x_grad

        if FLAGS.lnorm == -1:
            X = tf.maximum(tf.minimum(X, X_max), X_min)
        elif FLAGS.lnorm == 2:
            X = X_init + tf.clip_by_norm(X - X_init, l2_norm / 255., axes=[1, 2, 3])
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



ebm_sandbox.py [714:728]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        print("Constructed loop {} of pgd attack".format(i))
        X_init = X
        if i == 0:
            X = X + tf.to_float(tf.random_uniform(tf.shape(X), minval=-8, maxval=9, dtype=tf.int32)) / 255.

        logit = compute_logit(X)
        loss = tf.nn.softmax_cross_entropy_with_logits_v2(labels=Y_GT, logits=logit)

        x_grad = tf.sign(tf.gradients(loss, [X])[0]) / 255.
        X = X + 2 * x_grad

        if FLAGS.lnorm == -1:
            X = tf.maximum(tf.minimum(X, X_max), X_min)
        elif FLAGS.lnorm == 2:
            X = X_init + tf.clip_by_norm(X - X_init, l2_norm / 255., axes=[1, 2, 3])
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



