YOLO2TensorFlow
YOLO2TensorFlow copied to clipboard
preprocess_data with tensorflow is slow
def test_tf(): with tf.Session() as sess: array=tf.ones([1024,5],dtype=tf.float32) t0=time.clock() out=0 for i in range(array.shape[0]): out+=array[i] out=sess.run([out]) t1=time.clock() print("test_tf:",out,t1-t0)
def test_np(): array=np.ones((1024,5),dtype=np.float32) print array.shape t0=time.clock() out=0 for i in range(array.shape[0]): out+=array[i] t1=time.clock() print("test_np:",out,t1-t0)
console output: ('test_tf:', [array([ 1024., 1024., 1024., 1024., 1024.], dtype=float32)], 2.395962) (1024, 5) ('test_np:', array([ 1024., 1024., 1024., 1024., 1024.], dtype=float32), 0.0008499999999997954)
why not prepare data with numpy?
- The data got from TFRecord is tensor. 2.The way you evaluate the speed is not appropriate for my code. It's more reasonable that we evaluate the speed with vectorization.