def _test_backend_mnist(self, classifier, x_test, y_test):
    x_test_original = x_test.copy()
    df = VirtualAdversarialMethod(classifier, batch_size=100, max_iter=2)
    x_test_adv = df.generate(x_test)
    self.assertFalse((x_test == x_test_adv).all())
    y_pred = get_labels_np_array(classifier.predict(x_test_adv))
    self.assertFalse((y_test == y_pred).all())
    acc = (np.sum((np.argmax(y_pred, axis=1) == np.argmax(y_test, axis=1))) / y_test.shape[0])
    logger.info('Accuracy on adversarial examples: %.2f%%', (acc * 100))
    self.assertAlmostEqual(float(np.max(np.abs((x_test_original - x_test)))), 0.0, delta=1e-05)
def _test_backend_mnist(self, classifier, x_test, y_test):
    x_test_original = x_test.copy()
    df = VirtualAdversarialMethod(classifier, batch_size=100, max_iter=2)
    x_test_adv = df.generate(x_test)
    self.assertFalse((x_test == x_test_adv).all())
    y_pred = get_labels_np_array(classifier.predict(x_test_adv))
    self.assertFalse((y_test == y_pred).all())
    acc = (np.sum((np.argmax(y_pred, axis=1) == np.argmax(y_test, axis=1))) / y_test.shape[0])
    logger.info('Accuracy on adversarial examples: %.2f%%', (acc * 100))
    self.assertAlmostEqual(float(np.max(np.abs((x_test_original - x_test)))), 0.0, delta=1e-05)