failout_survival_rate = failout_survival_setting[i]
            # node failed
            layer_name = node
            layer = model.get_layer(name=layer_name)
            layer_weights = layer.get_weights()
            # make new weights for the connections
            new_weights = layer_weights[0] * failout_survival_rate

            # make new weights for biases
            new_bias_weights = layer_weights[1] * failout_survival_rate
            layer.set_weights([new_weights, new_bias_weights])


# runs all 3 failure configurations for all 3 models
if __name__ == "__main__":
    accuracy = accuracy("Health")
    calc_expected_accuracy = accuracy.calc_expected_accuracy
    data, num_vars = init_data()

    load_for_inference = False
    failout_survival_settings = [
        [0.95, 0.95, 0.95],
        [0.9, 0.9, 0.9],
        [0.7, 0.7, 0.7],
        [0.5, 0.5, 0.5],
    ]
    no_information_flow_map = make_no_information_flow_map(
        "Health", default_skip_hyperconnection_config)
    # file name with the experiments accuracy output
    mux_adds_str = "mux_adds" if ResiliNetPlus else ""
    output_name = "results/health_failout_rate" + mux_adds_str + ".txt"
Ejemplo n.º 2
0
    output_list.append(model_name + str(skip_hyperconnection_configuration) +
                       "\n")
    print(model_name + str(skip_hyperconnection_configuration))
    output[model_name][str(reliability_setting)][str(
        skip_hyperconnection_configuration)][iteration -
                                             1] = calc_expected_accuracy(
                                                 model,
                                                 no_information_flow_map,
                                                 reliability_setting,
                                                 output_list,
                                                 data=data,
                                             )


if __name__ == "__main__":
    accuracy = accuracy("Camera")
    calc_expected_accuracy = accuracy.calc_expected_accuracy
    data = init_data()

    skip_hyperconnection_configurations = [
        # [f2,f3,f4,e1,e2,e3,e4]
        [1, 1, 1, 1, 0, 0, 0],
        [1, 0, 0, 0, 0, 0, 1],
        [1, 0, 0, 0, 1, 0, 0],
        [0, 0, 0, 0, 1, 0, 1],
        [0, 0, 0, 0, 0, 0, 1],
        [0, 0, 0, 0, 0, 1, 1],
        [1, 1, 1, 1, 0, 0, 1],
        [1, 1, 1, 1, 1, 1, 1],
    ]
    no_information_flow_map = {}
        data,
        train_datagen,
        batch_size,
        epochs,
        progress_verbose,
        checkpoint_verbose,
        train_steps_per_epoch,
        val_steps_per_epoch,
        num_gpus,
    )
    return model


#  hyperconnection weight experiment
if __name__ == "__main__":
    accuracy = accuracy("ResNet")
    calc_expected_accuracy = accuracy.calc_expected_accuracy
    data = init_data()

    model_name = "ResiliNet Hyperconnection Weight"
    output, weight_schemes = make_output_dictionary_hyperconnection_weight(
        model_name, reliability_settings, num_iterations)
    considered_weight_schemes = [1, 2, 3, 4]

    no_information_flow_map = make_no_information_flow_map(
        "ResNet", default_skip_hyperconnection_config)

    load_for_inference = False
    train_steps_per_epoch = math.ceil(len(data.train) / batch_size)
    val_steps_per_epoch = math.ceil(len(data.val) / batch_size)
        model_file,
        data,
        train_datagen,
        batch_size,
        epochs,
        progress_verbose,
        checkpoint_verbose,
        train_steps_per_epoch,
        val_steps_per_epoch,
        num_gpus,
    )
    return model


if __name__ == "__main__":
    accuracy = accuracy("CIFAR")
    calc_expected_accuracy = accuracy.calc_expected_accuracy
    data = init_data()

    ResiliNet_no_information_flow_map = make_no_information_flow_map(
        "CIFAR/Imagenet", default_skip_hyperconnection_config)
    DFG_no_information_flow_map = make_no_information_flow_map(
        "CIFAR/Imagenet", default_skip_hyperconnection_config)
    Vanilla_no_information_flow_map = make_no_information_flow_map(
        "CIFAR/Imagenet")

    train_steps_per_epoch = math.ceil(len(data.train) / batch_size)
    val_steps_per_epoch = math.ceil(len(data.val) / batch_size)

    output = make_output_dictionary_average_accuracy(reliability_settings,
                                                     num_iterations)
    print(model_name)
    output[model_name][str(reliability_setting)][
        iteration - 1
    ] = calc_expected_accuracy(
        model,
        no_information_flow_map,
        reliability_setting,
        output_list,
        test_generator=test_generator,
        num_test_examples=num_test_examples,
    )


# runs all 3 failure configurations for all 3 models
if __name__ == "__main__":
    accuracy = accuracy("Imagenet")
    calc_expected_accuracy = accuracy.calc_expected_accuracy

    train_generator, test_generator = init_data(num_gpus)

    ResiliNet_no_information_flow_map = make_no_information_flow_map(
        "CIFAR/Imagenet", default_skip_hyperconnection_config
    )
    DFG_no_information_flow_map = make_no_information_flow_map(
        "CIFAR/Imagenet", default_skip_hyperconnection_config
    )
    Vanilla_no_information_flow_map = make_no_information_flow_map("CIFAR/Imagenet")

    load_for_inference = False
    continue_training = (
        False  # loads a pre-trained model and improves it with more training