• Creates rank-0 tf.Tensor (scalar) with the provided value and dtype.

    The same functionality can be achieved with tf.tensor, but in general we recommend using tf.scalar as it makes the code more readable.

    tf.scalar(3.14).print();
    

    Parameters

    • value: string | number | boolean | Uint8Array

      The value of the scalar.

    • Optional dtype: keyof DataTypeMap

      The data type.

    Returns Scalar

    Doc