Commit 158c9be0 authored by 赵威's avatar 赵威

update model path

parent 1a32da74
......@@ -33,13 +33,13 @@ if __name__ == "__main__":
diary_save_path = get_essm_model_save_path("diary")
if not diary_save_path:
diary_save_path = "/home/gmuser/data/models/diary/1597050209"
diary_save_path = "/data/files/models/diary/1597050209"
print(diary_save_path + "!!!!!!!!!!!!!!!!!!!!!!!!!!!")
diary_predict_fn = tf.contrib.predictor.from_saved_model(diary_save_path)
tractate_save_path = get_essm_model_save_path("tractate")
if not tractate_save_path:
tractate_save_path = "/home/gmuser/data/models/tractate/1596509299"
tractate_save_path = "/data/files/models/tractate/1596509299"
print(tractate_save_path + "!!!!!!!!!!!!!!!!!!!!!!!!!!!")
tractate_predict_fn = tf.contrib.predictor.from_saved_model(tractate_save_path)
......
......@@ -80,13 +80,13 @@ def main():
diary_save_path = get_essm_model_save_path("diary")
if not diary_save_path:
diary_save_path = "/home/gmuser/data/models/diary/1597379800"
diary_save_path = "/data/files/models/diary/1597379800"
print(diary_save_path + "!!!!!!!!!!!!!!!!!!!!!!!!!!!")
diary_predict_fn = tf.contrib.predictor.from_saved_model(diary_save_path)
tractate_save_path = get_essm_model_save_path("tractate")
if not tractate_save_path:
tractate_save_path = "/home/gmuser/data/models/tractate/1597378202"
tractate_save_path = "/data/files/models/tractate/1597378202"
print(tractate_save_path + "!!!!!!!!!!!!!!!!!!!!!!!!!!!")
tractate_predict_fn = tf.contrib.predictor.from_saved_model(tractate_save_path)
......
......@@ -45,13 +45,13 @@ if __name__ == "__main__":
diary_save_path = get_essm_model_save_path("diary")
if not diary_save_path:
diary_save_path = "/home/gmuser/data/models/diary/1597379800"
diary_save_path = "/data/files/models/diary/1597379800"
print(diary_save_path + "!!!!!!!!!!!!!!!!!!!!!!!!!!!")
diary_predict_fn = tf.contrib.predictor.from_saved_model(diary_save_path)
tractate_save_path = get_essm_model_save_path("tractate")
if not tractate_save_path:
tractate_save_path = "/home/gmuser/data/models/tractate/1597378202"
tractate_save_path = "/data/files/models/tractate/1597378202"
print(tractate_save_path + "!!!!!!!!!!!!!!!!!!!!!!!!!!!")
tractate_predict_fn = tf.contrib.predictor.from_saved_model(tractate_save_path)
......
import datetime
import time
import tensorflow as tf
from models.esmm.fe import device_fe, diary_fe, tractate_fe
from models.esmm.tractate_model import model_predict_tractate
from utils.cache import redis_client2
from utils.grey import recommed_service_category_device_id_by_tail
from utils.portrait import (get_user_portrait_tag3_read_v2, user_portrait_tag3_get_candidate_dict,
user_portrait_tag3_get_candidate_unread_list, user_portrait_tag3_write_ctcvr_data)
if __name__ == "__main__":
time_begin = time.time()
device_dict = device_fe.get_device_dict_from_redis()
tractate_dict = tractate_fe.get_tractate_dict_from_redis()
print("redis data: " + str(len(device_dict)) + " " + str(len(tractate_dict)))
device_id = "androidid_a25a1129c0b38f7b"
tractate_save_path = "/home/gmuser/data/models/tractate/1596092061"
tractate_predict_fn = tf.contrib.predictor.from_saved_model(tractate_save_path)
tractate_ids = user_portrait_tag3_get_candidate_unread_list(device_id, "tractate")
print("tractate_ids: " + str(len(tractate_ids)))
res = model_predict_tractate(device_id, tractate_ids, device_dict, tractate_dict, tractate_predict_fn)
print("res: " + str(len(res)))
print(res[:10])
user_portrait_tag3_write_ctcvr_data(device_id, "tractate", res[:500])
total_time = (time.time() - time_begin) / 60
print("total cost {:.2f} mins at {}".format(total_time, datetime.datetime.now()))
......@@ -51,7 +51,7 @@ def main():
all_features = fe.build_features(df, diary_fe.INT_COLUMNS, diary_fe.FLOAT_COLUMNS, diary_fe.CATEGORICAL_COLUMNS)
params = {"feature_columns": all_features, "hidden_units": [64, 32], "learning_rate": 0.1}
model_path = str(Path("~/data/model_tmp/diary/").expanduser())
model_path = str(Path("/data/files/model_tmp/diary/").expanduser())
if os.path.exists(model_path):
shutil.rmtree(model_path)
......@@ -70,14 +70,14 @@ def main():
print("ctcvr_auc: " + str(res[0]["ctcvr_auc"]))
print("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@")
model_export_path = str(Path("~/data/models/diary").expanduser())
model_export_path = str(Path("/data/files/models/diary").expanduser())
save_path = model_export(model, all_features, model_export_path)
print("save to: " + save_path)
set_essm_model_save_path("diary", save_path)
print("============================================================")
# save_path = str(Path("~/Desktop/models/1596012827").expanduser()) # local
# save_path = "/home/gmuser/data/models/diary/1596083349" # server
# save_path = "/data/files/models/diary/1596083349" # server
# tf.saved_model.load
......
......@@ -48,7 +48,7 @@ def main():
all_features = fe.build_features(df, tractate_fe.INT_COLUMNS, tractate_fe.FLOAT_COLUMNS, tractate_fe.CATEGORICAL_COLUMNS)
params = {"feature_columns": all_features, "hidden_units": [64, 32], "learning_rate": 0.1}
model_path = str(Path("~/data/model_tmp/tractate/").expanduser())
model_path = str(Path("/data/files/model_tmp/tractate/").expanduser())
if os.path.exists(model_path):
shutil.rmtree(model_path)
......@@ -67,14 +67,14 @@ def main():
print("ctcvr_auc: " + str(res[0]["ctcvr_auc"]))
print("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@")
model_export_path = str(Path("~/data/models/tractate/").expanduser())
model_export_path = str(Path("/data/files/models/tractate/").expanduser())
save_path = model_export(model, all_features, model_export_path)
print("save to: " + save_path)
set_essm_model_save_path("tractate", save_path)
print("============================================================")
# # save_path = str(Path("~/data/models/tractate/1596089465").expanduser()) # local
# save_path = "/home/gmuser/data/models/tractate/1596092061" # server
# save_path = "/data/files/models/tractate/1596092061" # server
predict_fn = tf.contrib.predictor.from_saved_model(save_path)
device_dict = device_fe.get_device_dict_from_redis()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment