在使用Tensorflow和Python绑定时,如何将张量转换为numpy数组?
发布于 2015-12-05 04:59:39
要将张量转换回numpy数组,只需对转换后的张量运行.eval()
即可。
发布于 2017-03-21 19:32:42
也许你可以试试这个方法:
import tensorflow as tf
W1 = tf.Variable(tf.random_uniform([1], -1.0, 1.0))
init = tf.global_variables_initializer()
sess = tf.Session()
sess.run(init)
array = W1.eval(sess)
print (array)
发布于 2020-05-05 13:44:11
为了这个命令我已经找了好几天了。
在任何会议或类似的事情之外,这对我都是有效的。
# you get an array = your tensor.eval(session=tf.compat.v1.Session())
an_array = a_tensor.eval(session=tf.compat.v1.Session())
https://kite.com/python/answers/how-to-convert-a-tensorflow-tensor-to-a-numpy-array-in-python
https://stackoverflow.com/questions/34097281
复制相似问题