|View source on GitHub|
x is a TF-native type that can be passed to many TF ops.
Compat aliases for migration
See Migration guide for more details.
tf.is_tensor( x )
Use is_tensor to differentiate types that can ingested by TensorFlow ops without any conversion (e.g.,
tf.RaggedTensor) from types that need to be converted into tensors before they are ingested (e.g., numpy
ndarray and Python scalars).
For example, in the following code block:
if not tf.is_tensor(t): t = tf.convert_to_tensor(t) return t.dtype
we check to make sure that
t is a tensor (and convert it if not) before accessing its
| ||A python object to check.|
© 2020 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 3.0.
Code samples licensed under the Apache 2.0 License.