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

type_value A value that can be converted to a tf.DType object.

A DType corresponding to type_value.

TypeError If type_value cannot be converted to a DType.