Reading TensorFlow docs: https://www.tensorflow.org/tutorials/customization/basics#numpy_compatibility
import numpy as np
ndarray = np.ones([3, 3])
print("TensorFlow operations convert numpy arrays to Tensors automatically")
tensor = tf.multiply(ndarray, 42)
print(tensor)
print("And NumPy operations convert Tensors to numpy arrays automatically")
print(np.add(tensor, 1))
print("The .numpy() method explicitly converts a Tensor to a numpy array")
print(tensor.numpy())
tensor = tf.multiply(ndarray, 42)
TF APIs support NumPy objects as inputs and this is easy to understand because TF APIs are just implemented to handle NumPy objects by TensorFlow Team.
But
print(np.add(tensor, 1))
On the contrary, why NumPy APIs could handle a tf.Tensor is quite amazing to me. Is this a mechanism that NumPy provided to handle any type of objects? Or just supported by Python in language level ? (I am new to Python)