def test_keras_iris_unbounded(self):
    classifier = get_tabular_classifier_kr()
    classifier = KerasClassifier(model=classifier._model, use_logits=False, channel_index=1)
    attack = VirtualAdversarialMethod(classifier, eps=1)
    x_test_iris_adv = attack.generate(self.x_test_iris)
    self.assertFalse((self.x_test_iris == x_test_iris_adv).all())
    self.assertTrue((x_test_iris_adv > 1).any())
    self.assertTrue((x_test_iris_adv < 0).any())
    preds_adv = np.argmax(classifier.predict(x_test_iris_adv), axis=1)
    self.assertFalse((np.argmax(self.y_test_iris, axis=1) == preds_adv).all())
    acc = (np.sum((preds_adv == np.argmax(self.y_test_iris, axis=1))) / self.y_test_iris.shape[0])
    logger.info('Accuracy on Iris with VAT adversarial examples: %.2f%%', (acc * 100))
def test_keras_iris_unbounded(self):
    classifier = get_tabular_classifier_kr()
    classifier = KerasClassifier(model=classifier._model, use_logits=False, channel_index=1)
    attack = VirtualAdversarialMethod(classifier, eps=1)
    x_test_iris_adv = attack.generate(self.x_test_iris)
    self.assertFalse((self.x_test_iris == x_test_iris_adv).all())
    self.assertTrue((x_test_iris_adv > 1).any())
    self.assertTrue((x_test_iris_adv < 0).any())
    preds_adv = np.argmax(classifier.predict(x_test_iris_adv), axis=1)
    self.assertFalse((np.argmax(self.y_test_iris, axis=1) == preds_adv).all())
    acc = (np.sum((preds_adv == np.argmax(self.y_test_iris, axis=1))) / self.y_test_iris.shape[0])
    logger.info('Accuracy on Iris with VAT adversarial examples: %.2f%%', (acc * 100))