Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/tensorflow/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Tensorflow性能:Numpy矩阵o TF矩阵?_Python_Tensorflow - Fatal编程技术网

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编译器。