Python Tensorflow性能:Numpy矩阵o TF矩阵?
我有以下代码:Python Tensorflow性能:Numpy矩阵o TF矩阵?,python,tensorflow,Python,Tensorflow,我有以下代码: with tf.Session() as sess: sess.run(init_vars) cols = sess.run(tf.shape(descriptors)[1]) descriptor_matrix = np.zeros((n_batches*batch_size, cols)) while True: batch_descriptor = sess.run(descriptors, feed_dict={dropou
with tf.Session() as sess:
sess.run(init_vars)
cols = sess.run(tf.shape(descriptors)[1])
descriptor_matrix = np.zeros((n_batches*batch_size, cols))
while True:
batch_descriptor = sess.run(descriptors, feed_dict={dropout_prob: 1})
descriptor_matrix[i:i+elements_in_batch] = np.array(batch_descriptor)
我混合了张量和numpy向量。这对性能有重要影响吗?为什么?我应该用张量来代替吗?把张量和numpy混合起来是没有问题的。 但在“图形”(sess.run())之外执行处理是不好的 Tensorflow/XLA编译器,用于生成“图形”以优化性能。 调用sess.run()时图形正在使用 但是,处理外部图形(sess.run())是普通的python代码。
它不受XLA编译器的影响。 < P>混合张量和NUMPY是没有问题的。 但在“图形”(sess.run())之外执行处理是不好的 Tensorflow/XLA编译器,用于生成“图形”以优化性能。 调用sess.run()时图形正在使用 但是,处理外部图形(sess.run())是普通的python代码。 它不受益于XLA编译器。