Commit ecc5c559 authored by 赵威's avatar 赵威

update timer

parent 3268d3e7
...@@ -47,11 +47,26 @@ def main(): ...@@ -47,11 +47,26 @@ def main():
# print(next(iter(predictions))) # print(next(iter(predictions)))
test_300 = test_df.sample(300) test_300 = test_df.sample(300)
test_300_2 = test_df.sample(300)
test_300_3 = test_df.sample(300)
predict_fn = tf.contrib.predictor.from_saved_model(save_path)
time_1 = timeit.default_timer() time_1 = timeit.default_timer()
model_predict(test_300, save_path) model_predict(test_300, predict_fn)
total_1 = (timeit.default_timer() - time_1) total_1 = (timeit.default_timer() - time_1)
print("prediction cost {:.5f} s".format(total_1)) print("prediction cost {:.5f} s".format(total_1))
time_2 = timeit.default_timer()
model_predict(test_300_2, predict_fn)
total_2 = (timeit.default_timer() - time_2)
print("prediction cost {:.5f} s".format(total_2))
time_3 = timeit.default_timer()
model_predict(test_300_3, predict_fn)
total_3 = (timeit.default_timer() - time_3)
print("prediction cost {:.5f} s".format(total_3))
total_time = (time.time() - time_begin) / 60 total_time = (time.time() - time_begin) / 60
print("cost {:.2f} mins at {}".format(total_time, datetime.now())) print("cost {:.2f} mins at {}".format(total_time, datetime.now()))
......
...@@ -89,8 +89,8 @@ def _bytes_feature(value): ...@@ -89,8 +89,8 @@ def _bytes_feature(value):
return tf.train.Feature(bytes_list=tf.train.BytesList(value=[value])) return tf.train.Feature(bytes_list=tf.train.BytesList(value=[value]))
def model_predict(inputs, model_path): def model_predict(inputs, predict_fn):
predict_fn = tf.contrib.predictor.from_saved_model(model_path)
int_columns = [ int_columns = [
"active_type", "active_days", "card_id", "is_pure_author", "is_have_reply", "is_have_pure_reply", "content_level", "active_type", "active_days", "card_id", "is_pure_author", "is_have_reply", "is_have_pure_reply", "content_level",
"topic_num", "favor_num", "vote_num" "topic_num", "favor_num", "vote_num"
......
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