Class ToNumber<T extends TNumber>

java.lang.Object
org.tensorflow.op.RawOp
org.tensorflow.op.strings.ToNumber<T>
All Implemented Interfaces:
Shaped, Op, Operand<T>

@Operator(group="strings") public final class ToNumber<T extends TNumber> extends RawOp implements Operand<T>
Converts each string in the input Tensor to the specified numeric type. (Note that int32 overflow results in an error while float overflow results in a rounded value.)

Example:

strings = ["5.0", "3.0", "7.0"] tf.strings.to_number(strings) <tf.Tensor: shape=(3,), dtype=float32, numpy=array([5., 3., 7.], dtype=float32)>

  • Field Details

  • Constructor Details

    • ToNumber

      public ToNumber(Operation operation)
  • Method Details

    • create

      @Endpoint(describeByClass=true) public static <T extends TNumber> ToNumber<T> create(Scope scope, Operand<TString> stringTensor, Class<T> outType)
      Factory method to create a class wrapping a new StringToNumber operation.
      Type Parameters:
      T - data type for StringToNumber output and operands
      Parameters:
      scope - current scope
      stringTensor - The stringTensor value
      outType - The numeric type to interpret each string in string_tensor as.
      Returns:
      a new instance of ToNumber
    • create

      @Endpoint(describeByClass=true) public static ToNumber<TFloat32> create(Scope scope, Operand<TString> stringTensor)
      Factory method to create a class wrapping a new StringToNumber operation, with the default output types.
      Parameters:
      scope - current scope
      stringTensor - The stringTensor value
      Returns:
      a new instance of ToNumber, with default output types
    • output

      public Output<T> output()
      Gets output. A Tensor of the same shape as the input string_tensor.
      Returns:
      output.
    • asOutput

      public Output<T> asOutput()
      Description copied from interface: Operand
      Returns the symbolic handle of the tensor.

      Inputs to TensorFlow operations are outputs of another TensorFlow operation. This method is used to obtain a symbolic handle that represents the computation of the input.

      Specified by:
      asOutput in interface Operand<T extends TNumber>
      See Also: