Example #1
0
        test_y = 1 - test_y

    # assert np.max(train_x) == 1, "train_x maximum is not 1, butfa {}.".format(np.max(train_x))
    assert np.max(train_y) == 1, "train_y maximum is not 1, but {}.".format(
        np.max(train_y))
    # assert np.max(test_x) <= 1, "test_x maximum is greater 1: {}.".format(np.max(test_x))
    assert np.max(test_y) <= 1, "test_y maximum is greater 1: {}.".format(
        np.max(test_y))
    print(train_x.shape, train_y.shape, test_x.shape, test_y.shape)

    ############################################################################################################
    # Preparation
    ############################################################################################################
    if not os.path.exists(path_results):
        os.mkdir(path_results)
    path_saving = init.initialize_folder(algorithm=algorithm_name + "Tracker",
                                         base_folder=path_results)

    ############################################################################################################
    # Model Training
    ############################################################################################################
    if algorithm_name == "CycleGAN":
        raise
    elif algorithm_name == "Pix2PixGAN":
        raise
    elif algorithm_name == "CVAEGAN":
        init_params = {
            "x_dim": inpt_dim,
            "y_dim": opt_dim,
            "z_dim": z_dim,
            "enc_architecture": enc_architecture,
            "gen_architecture": gen_architecture,
Example #2
0
    elif dropout:
        len_adv = len(architecture_adv)
        [architecture_adv.insert(1+2*i, [tf.layers.dropout, {}]) for i in range(len_adv-1)]


    architecture_aux = [
                      [tf.layers.conv2d, {"filters": 64, "kernel_size": 2, "strides": 2, "activation": activation}],
                      [tf.layers.conv2d, {"filters": 128, "kernel_size": 2, "strides": 2, "activation": activation}],
                      [tf.layers.conv2d, {"filters": 256, "kernel_size": 2, "strides": 2, "activation": activation}],
                      [tf.layers.conv2d, {"filters": 256, "kernel_size": 2, "strides": 2, "activation": activation}],
                      ]

    ############################################################################################################
    # Data loading
    ############################################################################################################
    path_saving = init.initialize_folder(algorithm=algorithm, base_folder=path_results)
    path_loading += "/Batches"
    copyfile(path_loading+"/Scalers.pickle", path_saving+"/Scalers.pickle")
    with open(path_loading+"/BatchX_Logging.pickle", "rb") as f:
        logging_calo = pickle.load(f)
    with open(path_loading+"/BatchY_Logging.pickle", "rb") as f:
        logging_tracker = pickle.load(f)
    with open(path_loading+"/BatchX_Test.pickle", "rb") as f:
        test_calo = pickle.load(f)
    with open(path_loading+"/BatchY_Test.pickle", "rb") as f:
        test_tracker = pickle.load(f)

    path_x_batches = path_loading + "/BatchesX"
    path_y_batches = path_loading + "/BatchesY"

    nr_test = test_calo.shape[0]
Example #3
0
        architectures = GenerativeModel.load_from_json(architecture_path)
        enc_architecture = architectures["Encoder"]
        gen_architecture = architectures["Generator"]
        adversarial_architecture = architectures["Adversarial"]

        if is_patchGAN and is_wasserstein:
            adversarial_architecture[-1][1]["activation"] = tf.identity
            adversarial_architecture[-1][1]["filters"] = 1
        elif is_patchGAN and not is_wasserstein:
            adversarial_architecture[-1][1]["activation"] = tf.nn.sigmoid
            adversarial_architecture[-1][1]["filters"] = 1
        elif not is_patchGAN:
            adversarial_architecture[-1][1]["activation"] = tf.nn.leaky_relu

        path_saving = "../../../Results/Test"
        path_saving = init.initialize_folder(algorithm="CVAEGAN_",
                                             base_folder=path_saving)

        init_params = {
            "x_dim": inpt_dim,
            "y_dim": opt_dim,
            "z_dim": z_dim,
            "enc_architecture": enc_architecture,
            "gen_architecture": gen_architecture,
            "adversarial_architecture": adversarial_architecture,
            "folder": path_saving,
            "is_patchgan": is_patchGAN,
            "is_wasserstein": is_wasserstein
        }
        compile_params = {
            "loss": loss,
            "learning_rate": learning_rate,
Example #4
0
        architectures = GenerativeModel.load_from_json(architecture_path)
        enc_architecture = architectures["Encoder"]
        gen_architecture = architectures["Generator"]
        adversarial_architecture = architectures["Adversarial"]

        if is_patchGAN and is_wasserstein:
            adversarial_architecture[-1][1]["activation"] = tf.identity
            adversarial_architecture[-1][1]["filters"] = 1
        elif is_patchGAN and not is_wasserstein:
            adversarial_architecture[-1][1]["activation"] = tf.nn.sigmoid
            adversarial_architecture[-1][1]["filters"] = 1
        elif not is_patchGAN:
            adversarial_architecture[-1][1]["activation"] = tf.nn.leaky_relu

        path_saving = "../../../Results/Test"
        path_saving = init.initialize_folder(algorithm="BiCycleGAN_",
                                             base_folder=path_saving)
        print(path_saving)

        init_params = {
            "x_dim": inpt_dim,
            "y_dim": opt_dim,
            "z_dim": z_dim,
            "enc_architecture": enc_architecture,
            "gen_architecture": gen_architecture,
            "adversarial_architecture": adversarial_architecture,
            "folder": path_saving,
            "is_patchgan": is_patchGAN,
            "is_wasserstein": is_wasserstein
        }
        compile_params = {
            "loss": loss,
Example #5
0
        batch_log_step = int(len(x_train) / batch_size / 20)
        gen_steps = 1
        label_smoothing = 0.95

        architectures = GenerativeModel.load_from_json(architecture_path)
        gen_architecture = architectures["Generator"]
        disc_architecture = architectures["Discriminator"]

        if is_patchGAN:
            disc_architecture[-1][1]["activation"] = tf.nn.sigmoid
            disc_architecture[-1][1]["filters"] = 1
        else:
            disc_architecture[-1][1]["activation"] = tf.nn.leaky_relu

        path_saving = "../../../Results/Test"
        path_saving = init.initialize_folder(algorithm="Pix2Pix_",
                                             base_folder=path_saving)

        init_params = {
            "x_dim": inpt_dim,
            "y_dim": opt_dim,
            "gen_architecture": gen_architecture,
            "disc_architecture": disc_architecture,
            "folder": path_saving,
            "is_patchgan": is_patchGAN
        }
        compile_params = {
            "loss": loss,
            "learning_rate": learning_rate,
            "learning_rate_disc": learning_rate_disc,
            "optimizer": optimizer,
            "lmbda": lmbda,