W3cubDocs

/TensorFlow

tf.dtypes.as_dtype

Converts the given type_value to a tf.DType.

Inputs can be existing tf.DType objects, a DataType enum, a string type name, or a numpy.dtype.

Examples:

tf.as_dtype(2)  # Enum value for float64.
tf.float64
tf.as_dtype('float')
tf.float32
tf.as_dtype(np.int32)
tf.int32
Note: DType values are interned (i.e. a single instance of each dtype is stored in a map). When passed a new DType object, as_dtype always returns the interned value.
Args
type_value A value that can be converted to a tf.DType object.
Returns
A DType corresponding to type_value.
Raises
TypeError If type_value cannot be converted to a DType.

© 2022 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 4.0.
Code samples licensed under the Apache 2.0 License.
https://www.tensorflow.org/api_docs/python/tf/dtypes/as_dtype