Esempio n. 1
0
            for k in range(len(weights)):

                new_fc_node = nodes.FullyConnectedNode(f"FC_{k}",
                                                       (weights[k].shape[1], ),
                                                       weights[k].shape[0],
                                                       weights[k], biases[k],
                                                       True)
                network.add_node(new_fc_node)

                if k < len(weights) - 1:
                    new_relu_node = nodes.ReLUNode(f"ReLU_{k}",
                                                   (weights[k].shape[0], ))
                    network.add_node(new_relu_node)

            # Verification of the network of interest for the property of interest
            prop = ver.NeVerProperty(in_pred_mat, in_pred_bias, [out_pred_mat],
                                     [out_pred_bias])

            net_id = networks_ids[i][j]
            p_id = property_ids[i]

            logger_acas_stream.info(f"Verification Methodology: CEGAR")

            verifier = ver.NeverVerificationRef(max_n, search_params,
                                                precision, only_rel)

            time_start = time.perf_counter()
            safe, counter_example = verifier.verify(network, prop)
            time_end = time.perf_counter()
            logger_acas_file.info(
                f"ACASXU,{net_id},{property_ids[i]},CEGAR,SIG={significance},MaxN={max_n}{safe},"
                f"{time_end - time_start}")
Esempio n. 2
0
in_pred_bias = np.array(in_pred_bias)
in_pred_mat = np.array(in_pred_mat)

num_output = 10
out_pred_mat = []
for i in range(num_output):
    if i != adversarial_target:
        temp = np.zeros(num_output)
        temp[adversarial_target] = 1
        temp[i] = -1
        out_pred_mat.append(temp)

out_pred_mat = [np.array(out_pred_mat)]
out_pred_bias = [np.array([[0], [0], [0], [0], [0], [0], [0], [0], [0]])]

lr_property = ver.NeVerProperty(in_pred_mat, in_pred_bias, out_pred_mat,
                                out_pred_bias)

master_log_file = "logs/MNISTExperimentLog.txt"

ver_param_sets = [[False, 0, False, 0]]
param_set_id = ["Over-Approx"]

with open(master_log_file, "a") as master_log:
    master_log.write(f"Dataset,NetworkID,Methodology,Safety,Time\n")

for net_id in net_ids:

    net_path = "mnist_nets/" + net_id + ".onnx"
    net = conv.ONNXConverter().to_neural_network(
        conv.ONNXNetwork(net_id, onnx.load(net_path)))
    assert isinstance(net, networks.SequentialNetwork)