f8a5a458ff6a35e91ae9d705160d73cdcc8adf97,test.py,,,#,13

Before Change


// get adversarial examples
ADV_PATH = os.path.join(DATA_PATH, "adversarial", "mnist", "fgsm", "cnn", "relu", "")

for eps in range(1, 11):
    X = np.load(ADV_PATH + "eps%.2f_train.npy" % (eps/10))

    scores = model.evaluate(X, Y_train, verbose=args.verbose)
    v_print("\naccuracy on train adversarial with  %.2f eps: %.2f%%" % (eps/10, scores[1] * 100))

    X = np.load(ADV_PATH + "eps%.2f_test.npy" % (eps/10))

    scores = model.evaluate(X, Y_test, verbose=args.verbose)
    v_print("\naccuracy on test adversarial with %.2f eps: %.2f%%" % (eps/10, scores[1] * 100))

After Change


model = cnn.load_model(MODEL_PATH, "best-weights.h5")

// ------------------------------------------------------------------------------------------------------- TEST
results = {}

// get MNIST
(X_train, Y_train), (X_test, Y_test) = load_mnist()

// Test on true train instances
scores = model.evaluate(X_train, Y_train, verbose=args.verbose)
v_print("\naccuracy on train: %.2f%%" % (scores[1] * 100))
results["train_accuracy"] = scores[1] * 100

// Test on true test instances
scores = model.evaluate(X_test, Y_test, verbose=args.verbose)
v_print("\naccuracy on test: %.2f%%" % (scores[1] * 100))
results["test_accuracy"] = scores[1] * 10

// get adversarial examples
ADV_PATH = os.path.join(DATA_PATH, "adversarial", "mnist")

for filepath in get_npy_files(ADV_PATH):

    X = np.load(filepath)
    Y = Y_train if "_train" in filepath else Y_test

    scores = model.evaluate(X, Y, verbose=args.verbose)
    v_print("\naccuracy on %s: %.2f%%" % (filepath, scores[1] * 100))
    results[filepath] = scores[1]*100

with open(os.path.join(MODEL_PATH, "accuracies.json"), "w") as json_file:
    json.dump(results, json_file)
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 6

Instances


Project Name: IBM/adversarial-robustness-toolbox
Commit Name: f8a5a458ff6a35e91ae9d705160d73cdcc8adf97
Time: 2017-05-31
Author: valentina.zantedeschi@ibm.com
File Name: test.py
Class Name:
Method Name:


Project Name: pyinstaller/pyinstaller
Commit Name: a5505747ac8b1f3891a63363a9b86af480452f77
Time: 2018-05-29
Author: itsayellow+dev@gmail.com
File Name: PyInstaller/building/osx.py
Class Name: BUNDLE
Method Name: assemble


Project Name: DT42/BerryNet
Commit Name: 7633670d154df78fe56e4b2f9614ceaf3888e0fe
Time: 2018-02-08
Author: bofu@dt42.io
File Name: inference/classify_movidius_server.py
Class Name:
Method Name: server