def main(_):
    params = ModelParams()

    for key, value in params.__dict__.items():
        print(key, "=", value)

    if params.alg_name == "dnn":
        model = dnn.model_estimator(params)
    elif params.alg_name == "dnn_pool":
        model = dnn_pool.model_estimator(params)
    elif params.alg_name == "dnn_cate":
        model = dnn_cate.model_estimator(params)
    elif params.alg_name == "deepfm":
        model = deepfm.model_estimator(params)
    elif params.alg_name == "deepfm_pool":
        model = deepfm_pool.model_estimator(params)
    elif params.alg_name == "deepfm_cate":
        model = deepfm_cate.model_estimator(params)
    elif params.alg_name == "din":
        model = din.model_estimator(params)
    elif params.alg_name == "dinfm":
        model = dinfm.model_estimator(params)
    elif params.alg_name == "dien":
        model = dien.model_estimator(params)
    elif params.alg_name == "dnn_emb":
        model = dnn_emb.model_estimator(params)
    elif params.alg_name == "dnn_autoint":
        model = dnn_autoint.model_estimator(params)
    else:
        model = dnn.model_estimator(params)
        print("alg_name = %s is error" % params.alg_name)
        exit(-1)

    if params.action_type == "train":
        start_time = time.time()

        train_files = data_load.get_file_list(params.train_path)
        predict_files = data_load.get_file_list(params.predict_path)
        print("--------------train------------")
        trained_model_path = op.model_fit(model, params, train_files,
                                          predict_files)
        end_time = time.time()
        print("model_save training time: %.2f s" % (end_time - start_time))

        # save model_pb path to a file
        f = tf.gfile.GFile(params.model_pb + "/test", 'w')
        f.write(str(trained_model_path, encoding="utf-8"))

        print("--------------predict------------")
        op.model_predict(trained_model_path, predict_files, params)

    elif params.action_type == "pred":
        print("--------------predict------------")
        predict_files = data_load.get_file_list(params.predict_path)
        op.model_predict(
            '/Users/R.Stalker/PycharmProjects/deep_learing_estimator/files/model_save_pb/deepfm',
            predict_files, params)

    else:
        print("action_type = %s is error !!!" % params.action_type)
Exemplo n.º 2
0
def main(_):
    params = ModelParams()
    for key, value in params.__dict__.items():
        print(key, "=", value)

    print("---delete old data...")
    delete_dt = my_utils.shift_date_time(params.dt, -1)
    print("---delete_dt:", delete_dt)
    print(params.train_path[:-9] + delete_dt)
    print(params.predict_path[:-9] + delete_dt)
    shutil.rmtree(params.train_path[:-9] + delete_dt, ignore_errors=True)
    shutil.rmtree(params.predict_path[:-9] + delete_dt, ignore_errors=True)

    if params.alg_name == "dnn":
        model = dnn.model_estimator(params)
    elif params.alg_name == "deepfm":
        model = deepfm.model_estimator(params)
    elif params.alg_name == "deepfm_pool":
        model = deepfm_pool.model_estimator(params)
    elif params.alg_name == "din":
        model = din.model_estimator(params)
    elif params.alg_name == "dnn_pool":
        model = dnn_pool.model_estimator(params)
    elif params.alg_name == "dinfm":
        model = dinfm.model_estimator(params)
    elif params.alg_name == "dien":
        model = dien.model_estimator(params)
    elif params.alg_name == "dnn_autoint":
        model = dnn_autoint.model_estimator(params)
    else:
        model = dnn.model_estimator(params)
        print("alg_name = %s is error" % params.alg_name)
        exit(-1)

    if params.mode == "train":
        start_time = time.time()

        train_files = data_load.get_file_list(params.train_path)
        predict_files = data_load.get_file_list(params.predict_path)
        print("--------------train------------")
        trained_model_path = op.model_fit(model, params, train_files,
                                          predict_files)
        end_time = time.time()

        # save model_pb path to a file
        f = tf.gfile.GFile(params.model_pb[:-9] + "latest_model_path", 'w')
        f.write(str(trained_model_path, encoding="utf-8"))
        print("model_save training time: %.2f s" % (end_time - start_time))

        print("--------------predict------------")
        op.model_predict(trained_model_path, predict_files, params)
    elif params.mode == "eval":
        print("--------------predict------------")
        predict_files = data_load.get_file_list(params.predict_path)
        op.model_predict(params.model_pb, predict_files, params)
    else:
        print("action_type = %s is error !!!" % params.mode)
Exemplo n.º 3
0
def main(_):
    params = ModelParams()

    for key, value in params.__dict__.items():
        print(key, "=", value)

    if params.alg_name == "esmm":
        model = esmm.model_estimator(params)
    elif params.alg_name == "mmoe":
        model = mmoe.model_estimator(params)
    else:
        model = esmm.model_estimator(params)
        print("alg_name = %s is error" % params.alg_name)
        exit(-1)

    if params.action_type == "train":
        start_time = time.time()

        train_files = data_load.get_file_list(params.train_path)
        predict_files = data_load.get_file_list(params.predict_path)
        print("--------------train------------")
        trained_model_path = op.model_fit(model, params, train_files,
                                          predict_files)
        end_time = time.time()
        print("model_save training time: %.2f s" % (end_time - start_time))

        # save model_pb path to a file
        f = tf.gfile.GFile(params.model_pb + "/test", 'w')
        f.write(str(trained_model_path, encoding="utf-8"))

        print("--------------predict------------")
        op.model_predict(trained_model_path, predict_files, params)

    elif params.action_type == "pred":
        print("--------------predict------------")
        predict_files = data_load.get_file_list(params.predict_path)
        op.model_predict('files/model_save_pb/esmm/1582094784', predict_files,
                         params)

    else:
        print("action_type = %s is error !!!" % params.action_type)