tensorflow2优化sess.run() 代码样例
众所周知,TensorFlow运行瓶颈之一是调用sess.run()
目前问题:循环内部每次都要开启一次Session,效率极低
while True:
with tf.Session(graph=camera.graph) as sess:
res = sess.run(sess.graph.get_tensor_by_name('import/final_result:0'{
import/Placeholder:0": data_bytes
})
解决办法:只开启一次Session
with tf.Session(graph=camera.graph) as sess:
while True:
res = sess.run(sess.graph.get_tensor_by_name('import/final_result:0'{
import/Placeholder:0": data_bytes
})
欢迎大家交流学习,任何问题都可以留言