如何计算/测量Tensorflow模型的推理时间?

nwlls2ji  于 2023-02-09  发布在  其他
关注(0)|答案(1)|浏览(340)

我有两个TF模型,我想比较它们预测的速度。我知道TF模型有evaluate方法,每步推理输出ms。但是,有没有比这更高的精度?如果有,正确的方法是什么?

rsaldnfx

rsaldnfx1#

试试这个:

import time
start_time=time.time()
model.predict( etc.......
end_time=time.time()
duration= end_time-start_time
hours = tr_duration // 3600
minutes = (tr_duration - (hours * 3600)) // 60
seconds = tr_duration - ((hours * 3600) + (minutes * 60))
msg = f'training elapsed time was {str(hours)} hours, {minutes:4.1f} minutes, {seconds:4.2f} seconds)_
print (msg) # print out training duration time

相关问题