Exemplo n.º 1
0
            f"--search_teacher_folder {teacher_folder} "
            # -----[AUXILIARY]-----
            "--aux_store_root store/1.TEST "
            "--aux_console_output")
        cmd = cmd.strip()
        parser = student_search_parser(teacher_type=teacher_type)
        args = parser.parse_args(cmd.split(" "))
    else:  # 2. Running
        preset_parser = student_search_preset_parser()
        preset_args, unk = preset_parser.parse_known_args()
        teacher_type, dataset = preset_args.T, preset_args.D
        parser = student_search_parser(teacher_type=teacher_type)
        args = parser.parse_args(unk)
        assert args.search_teacher_folder is not None

    store_folder = setup_folder(store_root=args.aux_store_root,
                                project_name=args.name)
    folder = Path(store_folder)

    setup_logger(folder_path=folder, console_output=args.aux_console_output)
    setup_seed(args.seed)

    if args.gpu_teacher == args.gpu_student:
        gpu_str = args.gpu_teacher
        device_student = torch.device("cuda:0")
        device_teacher = torch.device("cuda:0")
    else:  # args.gpu_teacher != args.gpu_student:
        if args.gpu_teacher > args.gpu_student:
            gpu_str = f"{args.gpu_student},{args.gpu_teacher}"
            device_student = torch.device("cuda:0")
            device_teacher = torch.device("cuda:1")
        else:  # args.gpu_teacher < args.gpu_student:
Exemplo n.º 2
0
    data["block_shape"] = [int(t) for t in blocks.split(",")]

    data.update(patch)
    return data


if __name__ == "__main__":
    # DEBUG setup
    pack = {
        # "console_output": True,
        # "log_every": 20,
    }
    configs = parse_arg(**pack)

    # 0. setup folder and logger
    path = setup_folder(configs)
    configs.update({"store_path": path})
    logger.setup_logger(configs)

    # 1. setup env, seed and gpu
    environment_preset(configs)
    gpu_config = get_gpu_config(configs["occupy"])
    sess = tf.Session(config=gpu_config)

    # 2. prepare dataset
    data_loader = DataLoaderPretrain(configs, configs["min_freq"])
    train_set, test_set = data_loader.split()
    data_loader.save_dict()
    logging.info("item dict saved to itemdict.pkl")

    # 3. update model configs