當前位置: 首頁>>代碼示例>>Python>>正文


Python compat.integral_types方法代碼示例

本文整理匯總了Python中tensorflow.python.util.compat.integral_types方法的典型用法代碼示例。如果您正苦於以下問題:Python compat.integral_types方法的具體用法?Python compat.integral_types怎麽用?Python compat.integral_types使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在tensorflow.python.util.compat的用法示例。


在下文中一共展示了compat.integral_types方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __new__

# 需要導入模塊: from tensorflow.python.util import compat [as 別名]
# 或者: from tensorflow.python.util.compat import integral_types [as 別名]
def __new__(cls, key):
    if len(key) != 2:
      raise ValueError("key must have size 2, got %s." % len(key))

    if not isinstance(key[0], compat.integral_types) or not isinstance(
        key[1], compat.integral_types):
      raise TypeError("Invalid key %s. Must be unsigned integer values." % key)

    return super(cls, StrongHashSpec).__new__(cls, "stronghash", key) 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:11,代碼來源:lookup_ops.py

示例2: _FilterInt

# 需要導入模塊: from tensorflow.python.util import compat [as 別名]
# 或者: from tensorflow.python.util.compat import integral_types [as 別名]
def _FilterInt(v):
  if isinstance(v, (list, tuple)):
    return _FirstNotNone([_FilterInt(x) for x in v])
  return None if isinstance(v, compat.integral_types) else _NotNone(v) 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:6,代碼來源:tensor_util.py

示例3: sparse_row_envelope

# 需要導入模塊: from tensorflow.python.util import compat [as 別名]
# 或者: from tensorflow.python.util.compat import integral_types [as 別名]
def sparse_row_envelope(sparse_input, row_axis=0, col_axis=1, name=None):
  """Returns the length of each 'row' in a `SparseTensor`.

  For example, if `sparse_input` has indices `[[0,0], [2, 0], [2, 1], [2, 2]]`
  and shape `[3, 3]`, this function will return `[1, 0, 3]`.

  Args:
    sparse_input: a `SparseTensor` of rank at least 2.
    row_axis: An integer. The axis for the row of the envelope matrix. Default
      is 0.
    col_axis: An integer. The axis for the col of the envelope matrix. Default
      is 1.
    name: A name for the operation (optional).

  Returns:
    A one-dimensional `Tensor` whose entries correspond to the length of each
    row of `SparseTensor`.

  Raises:
    ValueError: If row_axis and col_axis are the same axis or they are not
      integers.
  """
  if not (isinstance(row_axis, compat.integral_types) and
          isinstance(col_axis, compat.integral_types)):
    raise ValueError("`row_axis` and `col_axis` must be integers.")

  if row_axis == col_axis:
    raise ValueError("Row and column can not be the same axis.")

  with ops.name_scope(name, "sparse_row_envelope", [sparse_input]):
    indices = sparse_input.indices
    row_indices = indices[:, row_axis]
    col_indices = indices[:, col_axis]
    num_rows = math_ops.cast(sparse_input.dense_shape[row_axis], dtypes.int32)
    row_envelope = math_ops.unsorted_segment_max(
        col_indices + 1, row_indices, num_rows, name=name)
    zeros = array_ops.zeros_like(row_envelope)
    return array_ops.where(row_envelope > zeros, row_envelope, zeros) 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:40,代碼來源:sparse_ops.py

示例4: _FilterInt

# 需要導入模塊: from tensorflow.python.util import compat [as 別名]
# 或者: from tensorflow.python.util.compat import integral_types [as 別名]
def _FilterInt(v):
  if isinstance(v, (list, tuple)):
    return _FirstNotNone([_FilterInt(x) for x in v])
  return None if isinstance(v, (compat.integral_types,
                                tensor_shape.Dimension)) else _NotNone(v) 
開發者ID:PacktPublishing,項目名稱:Serverless-Deep-Learning-with-TensorFlow-and-AWS-Lambda,代碼行數:7,代碼來源:tensor_util.py


注:本文中的tensorflow.python.util.compat.integral_types方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。