Exemple #1
0
def get_data_and_config(global_args):
    data_loader = DataLoader(global_args)
    train_set, test_set = data_loader.split()

    model_args = get_model_args(data_loader.item_nums, global_args)
    logging.info(dict_to_str(model_args, "Configurations"))

    return model_args, train_set, test_set
Exemple #2
0
def get_data_and_config(global_args):
    data_loader = DataLoader(global_args)
    train_set, test_set = data_loader.split()

    model_args = get_model_args(data_loader.item_nums, global_args)
    logging.info(dict_to_str(model_args, "Model Configurations"))

    if model_args["gen_sub_sess"]:
        train_set = data_loader.generate_sub_sessions(train_set,
                                                      model_args["pad_token"])

    return model_args, train_set, test_set
Exemple #3
0
def log_configs(args):
    logging.info(dict_to_str(args, "Global Configurations"))
Exemple #4
0
    # 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
    configs = update_model_args(data_loader.item_nums)
    logging.info(dict_to_str(configs, "Configurations"))

    # 4. create model
    model = NextItNet(configs)
    with tf.variable_scope(tf.get_variable_scope(), reuse=tf.AUTO_REUSE):
        optimizer = tf.train.AdamOptimizer(configs["lr"]).minimize(
            model.loss_train)

    # 5. launch the rocket
    start()

    sess.close()