tf.keras.ops.cast

Cast a tensor to the desired dtype.

x A tensor or variable.
dtype The target type.

A tensor of the specified dtype.

Example:

x = keras.ops.arange(4)
x = keras.ops.cast(x, dtype="float16")