TensorFlow tensor data with each other in the conversion numpy

numpy and tensor data into each other:

*Numpy2Tensor

Although TensorFlow network will be automatically converted when the input data for the Tensor Numpy to deal with, but we can also go to their own explicit conversion:
data_tensor = tf.convert_to_tensor (data_numpy )

*Tensor2Numpy

Network output result is still Tensor, when we use these results to perform the operation can only be performed by the Numpy data will appear inexplicable error. Solution:

with tf.Session() as sess:
data_numpy = data_tensor.eval()

Guess you like

Origin www.cnblogs.com/liuwenhua/p/11854655.html