Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

preprocess_data with tensorflow is slow #4

Open
adeagle opened this issue Nov 9, 2017 · 1 comment
Open

preprocess_data with tensorflow is slow #4

adeagle opened this issue Nov 9, 2017 · 1 comment

Comments

@adeagle
Copy link

adeagle commented Nov 9, 2017

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?

@PaulChongPeng
Copy link
Owner

PaulChongPeng commented Nov 9, 2017

  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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants