• Casts a tf.Tensor to a new dtype.

    const x = tf.tensor1d([1.5, 2.5, 3]);
    tf.cast(x, 'int32').print();

    Type Parameters

    Parameters

    • x: TensorLike | T

      The input tensor to be casted.

    • dtype: keyof DataTypeMap

      The dtype to cast the input tensor to.

    Returns T

    Doc