コード例 #1
0
def string_to_number_v1(string_tensor=None,
                        out_type=dtypes.float32,
                        name=None,
                        input=None):
    string_tensor = deprecation.deprecated_argument_lookup(
        "input", input, "string_tensor", string_tensor)
    return gen_parsing_ops.string_to_number(string_tensor, out_type, name)
コード例 #2
0
def _tf_int(x, base):
  if base not in (10, UNSPECIFIED):
    raise NotImplementedError('base {} not supported for int'.format(base))

  # TODO(mdan): We shouldn't assume int32.
  if x.dtype == dtypes.string:
    return gen_parsing_ops.string_to_number(x, out_type=dtypes.int32)
  return math_ops.cast(x, dtype=dtypes.int32)
コード例 #3
0
def _tf_int(x, base):
  if base not in (10, UNSPECIFIED):
    raise NotImplementedError('base {} not supported for int'.format(base))

  # TODO(mdan): We shouldn't assume int32.
  if x.dtype == dtypes.string:
    return gen_parsing_ops.string_to_number(x, out_type=dtypes.int32)
  return math_ops.cast(x, dtype=dtypes.int32)
コード例 #4
0
ファイル: string_ops.py プロジェクト: adit-chandra/tensorflow
def string_to_number_v1(
    string_tensor=None,
    out_type=dtypes.float32,
    name=None,
    input=None):
  string_tensor = deprecation.deprecated_argument_lookup(
      "input", input, "string_tensor", string_tensor)
  return gen_parsing_ops.string_to_number(string_tensor, out_type, name)
コード例 #5
0
def string_to_number(input, out_type=dtypes.float32, name=None):
    r"""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.)

  Args:
    input: A `Tensor` of type `string`.
    out_type: An optional `tf.DType` from: `tf.float32, tf.float64, tf.int32,
      tf.int64`. Defaults to `tf.float32`.
      The numeric type to interpret each string in `string_tensor` as.
    name: A name for the operation (optional).

  Returns:
    A `Tensor` of type `out_type`.
  """
    return gen_parsing_ops.string_to_number(input, out_type, name)
コード例 #6
0
ファイル: string_ops.py プロジェクト: Wajih-O/tensorflow
def string_to_number(input, out_type=dtypes.float32, name=None):
  r"""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.)

  Args:
    input: A `Tensor` of type `string`.
    out_type: An optional `tf.DType` from: `tf.float32, tf.float64, tf.int32,
      tf.int64`. Defaults to `tf.float32`.
      The numeric type to interpret each string in `string_tensor` as.
    name: A name for the operation (optional).

  Returns:
    A `Tensor` of type `out_type`.
  """
  return gen_parsing_ops.string_to_number(input, out_type, name)
コード例 #7
0
def _tf_float(x):
  # TODO(mdan): We shouldn't assume float32.
  if x.dtype == dtypes.string:
    return gen_parsing_ops.string_to_number(x, out_type=dtypes.float32)
  return math_ops.cast(x, dtype=dtypes.float32)
コード例 #8
0
def _tf_float(x):
  # TODO(mdan): We shouldn't assume float32.
  if x.dtype == dtypes.string:
    return gen_parsing_ops.string_to_number(x, out_type=dtypes.float32)
  return math_ops.cast(x, dtype=dtypes.float32)