In [5]:
import numpy as np

ndarray = np.ones([3, 3])

# convert numpy arrays to Tensors automatically
tensor = tf.multiply(ndarray, 42)
print(tensor)
print(type(tensor))

# convert Tensors to numpy arrays 
print(np.add(tensor, 1))

#.numpy() method explicitly converts a Tensor to a numpy array
print(tensor.numpy())
tf.Tensor(
[[42. 42. 42.]
 [42. 42. 42.]
 [42. 42. 42.]], shape=(3, 3), dtype=float64)
<class 'tensorflow.python.framework.ops.EagerTensor'>
[[43. 43. 43.]
 [43. 43. 43.]
 [43. 43. 43.]]
[[42. 42. 42.]
 [42. 42. 42.]
 [42. 42. 42.]]