本文整理汇总了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)
示例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)
示例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)
示例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