def prologue_fds_0(args,
                   OUTD,
                   COMMON,
                   SIMS,
                   VISION,
                   ROUNDS,
                   SHARED_OPT_MASKS
                   ):
    """
    Do some stuff before starting.
    :return:
    """
    lfolders = [OUTD, COMMON, SIMS, VISION, ROUNDS, SHARED_OPT_MASKS]

    for fdxx in lfolders:
        if not os.path.exists(fdxx):
            os.makedirs(fdxx)

    OUTD_TR = create_folders_for_exp(OUTD, "train")
    OUTD_VL = create_folders_for_exp(OUTD, "valid")
    OUTD_TS = create_folders_for_exp(OUTD, "test")
    OUTD_TLB = create_folders_for_exp(OUTD, "tlb")
    OUTD_LO = create_folders_for_exp(OUTD, "leftovers")

    OUTD_OPTMASKS = join(OUTD, "optim_masks")  # hosts many sub-folders.
    if not os.path.exists(OUTD_OPTMASKS):
        os.makedirs(OUTD_OPTMASKS)

    fd_p_msks = None
    if args.share_masks:
        msg = "{} is not a valid directory.".format(SHARED_OPT_MASKS)
        assert os.path.isdir(SHARED_OPT_MASKS), msg
        fd_p_msks = SHARED_OPT_MASKS
    else:
        msg = "{} is not a valid directory.".format(OUTD_OPTMASKS)
        fd_p_msks = join(OUTD_OPTMASKS, "bin_masks")  # it has already been
        # created.
        assert os.path.isdir(fd_p_msks), msg

    return {
        'OUTD_TR': OUTD_TR,
        'OUTD_VL': OUTD_VL,
        'OUTD_TS': OUTD_TS,
        'OUTD_TLB': OUTD_TLB,
        'OUTD_LO': OUTD_LO,
        'OUTD_OPTMASKS': OUTD_OPTMASKS,
        'fd_p_msks': fd_p_msks
    }
Ejemplo n.º 2
0
    OUTD = join(
        FOLDER,
        "exps",
        # "nbr_erase-{}-".format(args.nbr_times_erase),
        "PID-{}-{}-bsz-{}-kmax-kmin-{}-dout-{}-erase-nbr-{}-at-epoch-{}-max-epochs-{}-stepsize-"
        "{}-nbr-modalitities-{}-lr-{}-mx-epochs-{}".format(
            os.getpid(), get_exp_name(args), args.batch_size,
            args.model["kmax"], args.model["dropout"], args.nbr_times_erase,
            args.epoch_start_erasing, args.max_epochs,
            args.optimizer["lr_scheduler"]["step_size"],
            args.model["modalities"], args.optimizer["lr"], args.max_epochs))

    if not os.path.exists(OUTD):
        os.makedirs(OUTD)

    OUTD_TR = create_folders_for_exp(OUTD, "train")
    OUTD_VL = create_folders_for_exp(OUTD, "validation")
    OUTD_TS = create_folders_for_exp(OUTD, "test")

    subdirs = ["init_params"]
    for sbdr in subdirs:
        if not os.path.exists(join(OUTD, sbdr)):
            os.makedirs(join(OUTD, sbdr))

    # save the yaml file.
    if not os.path.exists(join(OUTD, "code/")):
        os.makedirs(join(OUTD, "code/"))
    with open(join(OUTD, "code/", input_args.yaml), 'w') as fyaml:
        yaml.dump(args_dict, fyaml)

    copy_code(join(OUTD, "code/"))