def define_and_train(
    iteration,
    model_name,
    load_for_inference,
    failout_survival_setting,
    data,
    batch_size,
    classes,
    input_shape,
    alpha,
    strides,
    train_datagen,
    epochs,
    progress_verbose,
    checkpoint_verbose,
    train_steps_per_epoch,
    val_steps_per_epoch,
    num_gpus,
):
    mux_adds_str = "mux_adds" if ResiliNetPlus else ""
    model_file = (
        "models/"
        + str(iteration)
        + " "
        + mux_adds_str
        + str(failout_survival_setting)
        + "cifar_failout_rate.h5"
    )
    model, parallel_model = define_ResiliNet_CNN_MobileNet(
        classes=classes,
        input_shape=input_shape,
        alpha=alpha,
        failout_survival_setting=failout_survival_setting,
        strides=strides,
        num_gpus=num_gpus,
    )
    get_model_weights_CNN_cifar(
        model,
        parallel_model,
        model_name,
        load_for_inference,
        model_file,
        data,
        train_datagen,
        batch_size,
        epochs,
        progress_verbose,
        checkpoint_verbose,
        train_steps_per_epoch,
        val_steps_per_epoch,
        num_gpus,
    )
    return model
def define_and_train(
    iteration,
    model_name,
    load_for_inference,
    data,
    batch_size,
    classes,
    input_shape,
    alpha,
    strides,
    train_datagen,
    epochs,
    progress_verbose,
    checkpoint_verbose,
    train_steps_per_epoch,
    val_steps_per_epoch,
    num_gpus,
):
    model, parallel_model, model_file = define_model(
        iteration,
        model_name,
        "cifar",
        input_shape,
        classes,
        alpha,
        strides,
        num_gpus,
        weights=None,
    )
    get_model_weights_CNN_cifar(
        model,
        parallel_model,
        model_name,
        load_for_inference,
        model_file,
        data,
        train_datagen,
        batch_size,
        epochs,
        progress_verbose,
        checkpoint_verbose,
        train_steps_per_epoch,
        val_steps_per_epoch,
        num_gpus,
    )
    return model
def define_and_train(
    iteration,
    model_name,
    load_for_inference,
    reliability_setting,
    weight_scheme,
    data,
    batch_size,
    classes,
    input_shape,
    alpha,
    strides,
    train_datagen,
    epochs,
    progress_verbose,
    checkpoint_verbose,
    train_steps_per_epoch,
    val_steps_per_epoch,
    num_gpus,
):
    if model_name == "DFG Hyperconnection Weight":
        model_file = ("models/" + str(iteration) + "_" +
                      str(reliability_setting) + "_" + str(weight_scheme) +
                      "cifar_resnet_hyperconnection_DFG.h5")
        model, parallel_model = define_DFG_CNN_ResNet(
            input_shape=input_shape,
            classes=classes,
            block="basic",
            residual_unit="v2",
            repetitions=[2, 2, 2, 2],
            initial_filters=64,
            activation="softmax",
            include_top=True,
            input_tensor=None,
            dropout=None,
            transition_dilation_rate=(1, 1),
            initial_strides=(2, 2),
            initial_kernel_size=(7, 7),
            initial_pooling="max",
            final_pooling=None,
            top="classification",
            skip_hyperconnection_config=
            default_skip_hyperconnection_config,  # binary representating if a skip hyperconnection is alive [e1,IoT]
            reliability_setting=reliability_setting,
            hyperconnection_weights_scheme=weight_scheme,
            num_gpus=num_gpus,
        )
    else:  # model_name is "ResiliNet Hyperconnection Weight"
        mux_adds_str = "mux_adds" if ResiliNetPlus else ""
        model_file = ("models/" + str(iteration) + "_" + mux_adds_str +
                      str(reliability_setting) + "_" + str(weight_scheme) +
                      "cifar_resnet_hyperconnection_ResiliNet.h5")
        model, parallel_model = define_ResiliNet_CNN_ResNet(
            input_shape=input_shape,
            classes=classes,
            block="basic",
            residual_unit="v2",
            repetitions=[2, 2, 2, 2],
            initial_filters=64,
            activation="softmax",
            include_top=True,
            input_tensor=None,
            dropout=None,
            transition_dilation_rate=(1, 1),
            initial_strides=(2, 2),
            initial_kernel_size=(7, 7),
            initial_pooling="max",
            final_pooling=None,
            top="classification",
            failout_survival_setting=[0.95, 0.95],
            skip_hyperconnection_config=default_skip_hyperconnection_config,
            reliability_setting=reliability_setting,
            hyperconnection_weights_scheme=weight_scheme,
            num_gpus=num_gpus,
        )
    get_model_weights_CNN_cifar(
        model,
        parallel_model,
        model_name,
        load_for_inference,
        model_file,
        data,
        train_datagen,
        batch_size,
        epochs,
        progress_verbose,
        checkpoint_verbose,
        train_steps_per_epoch,
        val_steps_per_epoch,
        num_gpus,
    )
    return model
def define_and_train(
    iteration,
    model_name,
    load_for_inference,
    reliability_setting,
    skip_hyperconnection_configuration,
    data,
    batch_size,
    classes,
    input_shape,
    alpha,
    strides,
    train_datagen,
    epochs,
    progress_verbose,
    checkpoint_verbose,
    train_steps_per_epoch,
    val_steps_per_epoch,
    num_gpus,
):
    if model_name == "DFG Hyperconnection Weight Sensitivity":
        model_file = ("models/" + str(iteration) + " " +
                      str(skip_hyperconnection_configuration) + " " +
                      "cifar_skiphyperconnection_sensitivity_DFG.h5")
        model, parallel_model = define_DFG_CNN_MobileNet(
            classes=classes,
            input_shape=input_shape,
            alpha=alpha,
            reliability_setting=reliability_setting,
            skip_hyperconnection_config=skip_hyperconnection_configuration,
            strides=strides,
            num_gpus=num_gpus,
        )
    else:  # model_name is "ResiliNet Hyperconnection Weight Sensitivity"
        mux_adds_str = "mux_adds" if ResiliNetPlus else ""
        model_file = ("models/" + str(iteration) + " " + mux_adds_str +
                      str(skip_hyperconnection_configuration) + " " +
                      "cifar_skiphyperconnection_sensitivity_ResiliNet.h5")
        model, parallel_model = define_ResiliNet_CNN_MobileNet(
            classes=classes,
            input_shape=input_shape,
            alpha=alpha,
            reliability_setting=reliability_setting,
            skip_hyperconnection_config=skip_hyperconnection_configuration,
            strides=strides,
            num_gpus=num_gpus,
        )
    get_model_weights_CNN_cifar(
        model,
        parallel_model,
        model_name,
        load_for_inference,
        model_file,
        data,
        train_datagen,
        batch_size,
        epochs,
        progress_verbose,
        checkpoint_verbose,
        train_steps_per_epoch,
        val_steps_per_epoch,
        num_gpus,
    )
    return model
예제 #5
0
def define_and_train(
    iteration,
    model_name,
    load_for_inference,
    failout_survival_setting,
    data,
    batch_size,
    classes,
    input_shape,
    alpha,
    strides,
    train_datagen,
    epochs,
    progress_verbose,
    checkpoint_verbose,
    train_steps_per_epoch,
    val_steps_per_epoch,
    num_gpus,
):
    mux_adds_str = "mux_adds" if ResiliNetPlus else ""
    model_file = (
        "models/"
        + str(iteration)
        + " "
        + mux_adds_str
        + str(failout_survival_setting)
        + "cifar_resnet_failout_rate.h5"
    )
    model, parallel_model = define_ResiliNet_CNN_ResNet(
        input_shape=input_shape,
        classes=classes,
        block="basic",
        residual_unit="v2",
        repetitions=[2, 2, 2, 2],
        initial_filters=64,
        activation="softmax",
        include_top=True,
        input_tensor=None,
        dropout=None,
        transition_dilation_rate=(1, 1),
        initial_strides=(2, 2),
        initial_kernel_size=(7, 7),
        initial_pooling="max",
        final_pooling=None,
        top="classification",
        failout_survival_setting=failout_survival_setting,
        skip_hyperconnection_config=default_skip_hyperconnection_config,
        num_gpus=num_gpus,
    )
    get_model_weights_CNN_cifar(
        model,
        parallel_model,
        model_name,
        load_for_inference,
        model_file,
        data,
        train_datagen,
        batch_size,
        epochs,
        progress_verbose,
        checkpoint_verbose,
        train_steps_per_epoch,
        val_steps_per_epoch,
        num_gpus,
    )
    return model