Skip to content

preprocess_data with tensorflow is slow #4

@adeagle

Description

@adeagle

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions