当前位置: 首页>>代码示例>>Python>>正文


Python compat.bytes_or_text_types方法代码示例

本文整理汇总了Python中tensorflow.python.util.compat.bytes_or_text_types方法的典型用法代码示例。如果您正苦于以下问题:Python compat.bytes_or_text_types方法的具体用法?Python compat.bytes_or_text_types怎么用?Python compat.bytes_or_text_types使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tensorflow.python.util.compat的用法示例。


在下文中一共展示了compat.bytes_or_text_types方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: assert_proper_iterable

# 需要导入模块: from tensorflow.python.util import compat [as 别名]
# 或者: from tensorflow.python.util.compat import bytes_or_text_types [as 别名]
def assert_proper_iterable(values):
  """Static assert that values is a "proper" iterable.

  `Ops` that expect iterables of `Tensor` can call this to validate input.
  Useful since `Tensor`, `ndarray`, byte/text type are all iterables themselves.

  Args:
    values:  Object to be checked.

  Raises:
    TypeError:  If `values` is not iterable or is one of
      `Tensor`, `SparseTensor`, `np.array`, `tf.compat.bytes_or_text_types`.
  """
  unintentional_iterables = (
      (ops.Tensor, sparse_tensor.SparseTensor, np.ndarray)
      + compat.bytes_or_text_types
  )
  if isinstance(values, unintentional_iterables):
    raise TypeError(
        'Expected argument "values" to be a "proper" iterable.  Found: %s' %
        type(values))

  if not hasattr(values, '__iter__'):
    raise TypeError(
        'Expected argument "values" to be iterable.  Found: %s' % type(values)) 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:27,代码来源:check_ops.py

示例2: __init__

# 需要导入模块: from tensorflow.python.util import compat [as 别名]
# 或者: from tensorflow.python.util.compat import bytes_or_text_types [as 别名]
def __init__(self, value):
    """Creates a new Dimension with the given value."""
    if value is None:
      self._value = None
    else:
      self._value = int(value)
      if (not isinstance(value, compat.bytes_or_text_types) and
          self._value != value):
        raise ValueError("Ambiguous dimension: %s" % value)
      if self._value < 0:
        raise ValueError("Dimension %d must be >= 0" % self._value) 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:13,代码来源:tensor_shape.py

示例3: _MakeStr

# 需要导入模块: from tensorflow.python.util import compat [as 别名]
# 或者: from tensorflow.python.util.compat import bytes_or_text_types [as 别名]
def _MakeStr(v, arg_name):
  if not isinstance(v, compat.bytes_or_text_types):
    raise TypeError("Expected string for argument '%s' not %s." %
                    (arg_name, repr(v)))
  return compat.as_bytes(v)  # Convert unicode strings to bytes. 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:7,代码来源:op_def_library.py

示例4: _FilterStr

# 需要导入模块: from tensorflow.python.util import compat [as 别名]
# 或者: from tensorflow.python.util.compat import bytes_or_text_types [as 别名]
def _FilterStr(v):
  if isinstance(v, (list, tuple)):
    return _FirstNotNone([_FilterStr(x) for x in v])
  if isinstance(v, compat.bytes_or_text_types):
    return None
  else:
    return _NotNone(v) 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:9,代码来源:tensor_util.py

示例5: __init__

# 需要导入模块: from tensorflow.python.util import compat [as 别名]
# 或者: from tensorflow.python.util.compat import bytes_or_text_types [as 别名]
def __init__(self, value):
    """Creates a new Dimension with the given value."""
    if value is None:
      self._value = None
    else:
      self._value = int(value)
      if (not isinstance(value, compat.bytes_or_text_types)
          and self._value != value):
        raise ValueError("Ambiguous dimension: %s" % value)
      if self._value < 0:
        raise ValueError("Dimension %d must be >= 0" % self._value) 
开发者ID:abhisuri97,项目名称:auto-alt-text-lambda-api,代码行数:13,代码来源:tensor_shape.py

示例6: _read_converted_names

# 需要导入模块: from tensorflow.python.util import compat [as 别名]
# 或者: from tensorflow.python.util.compat import bytes_or_text_types [as 别名]
def _read_converted_names(self, target):
        if isinstance(target, compat.bytes_or_text_types):
            target_name = target
        else:
            target_name = target.name
        if target_name in self._replica_dict:
            return self._replica_dict[target_name]
        else:
            return target 
开发者ID:snuspl,项目名称:parallax,代码行数:11,代码来源:session_context.py

示例7: _convert_feed

# 需要导入模块: from tensorflow.python.util import compat [as 别名]
# 或者: from tensorflow.python.util.compat import bytes_or_text_types [as 别名]
def _convert_feed(self, feed_dict):

        def _feed_fn(feed):
            for tensor_type, _, _, feed_fn in session._REGISTERED_EXPANSIONS:
                if isinstance(feed, tensor_type):
                    return feed_fn(feed)
            raise TypeError('Feed argument %r has invalid type %r' % (feed,
                                                                   type(feed)))
        if feed_dict:
            new_feed_dict = {}
            for feed, feed_val in feed_dict.items():
                if isinstance(feed, compat.bytes_or_text_types):
                    new_feeds = self._read_converted_names(feed)
                    if isinstance(new_feeds, list):
                        for i in range(self._num_replicas_per_worker):
                            new_feed_dict[new_feeds[i]] = feed_val[i]
                    else:
                        new_feed_dict[new_feeds] = feed_val
                else:
                    for subfeed in _feed_fn(feed):
                        new_subfeeds = self._read_converted_names(subfeed)
                        if isinstance(new_subfeeds, list):
                            for i in range(self._num_replicas_per_worker):
                                new_feed_dict[new_subfeeds[i]] = feed_val[i]
                        else:
                            new_feed_dict[new_subfeeds] = feed_val
            return new_feed_dict
        else:
            return feed_dict 
开发者ID:snuspl,项目名称:parallax,代码行数:31,代码来源:session_context.py

示例8: make_str

# 需要导入模块: from tensorflow.python.util import compat [as 别名]
# 或者: from tensorflow.python.util.compat import bytes_or_text_types [as 别名]
def make_str(v, arg_name):
  if not isinstance(v, compat.bytes_or_text_types):
    raise TypeError("Expected string for argument '%s' not %s." %
                    (arg_name, repr(v)))
  return compat.as_bytes(v)  # Convert unicode strings to bytes. 
开发者ID:PacktPublishing,项目名称:Serverless-Deep-Learning-with-TensorFlow-and-AWS-Lambda,代码行数:7,代码来源:execute.py


注:本文中的tensorflow.python.util.compat.bytes_or_text_types方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。