Commit 14678a23 authored by 赵威's avatar 赵威

update model path

parent 37ebeeda
...@@ -57,7 +57,7 @@ def main(): ...@@ -57,7 +57,7 @@ def main():
eval_spec = tf.estimator.EvalSpec(input_fn=lambda: esmm_input_fn(val_df, shuffle=False)) eval_spec = tf.estimator.EvalSpec(input_fn=lambda: esmm_input_fn(val_df, shuffle=False))
tf.estimator.train_and_evaluate(model, train_spec, eval_spec) tf.estimator.train_and_evaluate(model, train_spec, eval_spec)
model_export_path = str(Path("~/data/models/").expanduser()) model_export_path = str(Path("~/data/models/diary").expanduser())
save_path = model_export(model, all_features, model_export_path) save_path = model_export(model, all_features, model_export_path)
print("save to: " + save_path) print("save to: " + save_path)
......
...@@ -25,8 +25,8 @@ def main(): ...@@ -25,8 +25,8 @@ def main():
cc_df = click_fe.click_feature_engineering(tractate_click_df, tractate_conversion_df) cc_df = click_fe.click_feature_engineering(tractate_click_df, tractate_conversion_df)
df = tractate_fe.join_features(device_df, tractate_df, cc_df) df = tractate_fe.join_features(device_df, tractate_df, cc_df)
for i in df.columns: # for i in df.columns:
print(i) # print(i)
# print(df.dtypes) # print(df.dtypes)
train_df, test_df = train_test_split(df, test_size=0.2) train_df, test_df = train_test_split(df, test_size=0.2)
...@@ -38,6 +38,20 @@ def main(): ...@@ -38,6 +38,20 @@ def main():
# if os.path.exists(model_path): # if os.path.exists(model_path):
# shutil.rmtree(model_path) # shutil.rmtree(model_path)
session_config = tf.compat.v1.ConfigProto()
session_config.gpu_options.allow_growth = True
session_config.gpu_options.per_process_gpu_memory_fraction = 0.9
estimator_config = tf.estimator.RunConfig(session_config=session_config)
model = tf.estimator.Estimator(model_fn=esmm_model_fn, params=params, model_dir=model_path, config=estimator_config)
train_spec = tf.estimator.TrainSpec(input_fn=lambda: esmm_input_fn(train_df, shuffle=True), max_steps=50000)
eval_spec = tf.estimator.EvalSpec(input_fn=lambda: esmm_input_fn(val_df, shuffle=False))
tf.estimator.train_and_evaluate(model, train_spec, eval_spec)
model_export_path = str(Path("~/data/models/tractate/").expanduser())
save_path = model_export(model, all_features, model_export_path)
print("save to: " + save_path)
total_time = (time.time() - time_begin) / 60 total_time = (time.time() - time_begin) / 60
print("total cost {:.2f} mins at {}".format(total_time, datetime.now())) print("total cost {:.2f} mins at {}".format(total_time, datetime.now()))
......
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