YOLO2TensorFlow icon indicating copy to clipboard operation
YOLO2TensorFlow copied to clipboard

preprocess_data with tensorflow is slow

Open adeagle opened this issue 7 years ago • 1 comments

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?

adeagle avatar Nov 09 '17 00:11 adeagle

  1. 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.

PaulChongPeng avatar Nov 09 '17 11:11 PaulChongPeng