def eval(model, x, y): y_pred = np.argmax(model.predict(x), axis=1) y_test = np.squeeze(y) bca = utils.bca(y_test, y_pred) acc = np.sum(y_pred == y_test).astype(np.float32) / len(y_pred) return acc, bca
# print(v.shape) y_adv_pre = np.argmax(model.predict(adv_x), axis=1) adv_acc = np.sum(y_adv_pre == y_test) / len(y_adv_pre) print('raw acc: ', raw_acc) print('rand_acc: ', rand_acc) print('adv_acc: ', adv_acc) # print(y_adv_pre) # print(y_test) # exit() raw_accs.append(raw_acc) rand_accs.append(rand_acc) adv_accs.append(adv_acc) raw_bca = utils.bca(y_test, y_test_pre) rand_bca = utils.bca(y_test, y_rand_pre) adv_bca = utils.bca(y_test, y_adv_pre) raw_bcas.append(raw_bca) rand_bcas.append(rand_bca) adv_bcas.append(adv_bca) np.savez(os.path.join(checkpoint_path, 'adv_v.npz'), v=v) K.clear_session() print(raw_accs) print(rand_accs) print(adv_accs) print('\n') print(raw_bcas) print(rand_bcas)