Tensorflow: How do I convert a EagerTensor into a numpy array?
There is a .numpy()
function which you can use, alternatively you could also do numpy.array(y)
. For example:
import tensorflow as tf
import numpy as np
tf.enable_eager_execution()
x = tf.constant([1., 2.])
print(type(x)) # <type 'EagerTensor'>
print(type(x.numpy())) # <type 'numpy.ndarray'>
print(type(np.array(x))) # <type 'numpy.ndarray'>
See the section in the eager execution guide.
Hope that helps.