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


Python framework.is_tensor方法代码示例

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


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

示例1: _verify_input_args

# 需要导入模块: from tensorflow.contrib import framework [as 别名]
# 或者: from tensorflow.contrib.framework import is_tensor [as 别名]
def _verify_input_args(x, y, input_fn, feed_fn, batch_size):
  """Verifies validity of co-existance of input arguments."""
  if input_fn is None:
    if x is None:
      raise ValueError('Either x or input_fn must be provided.')

    if contrib_framework.is_tensor(x) or (y is not None and
                                          contrib_framework.is_tensor(y)):
      raise ValueError('Inputs cannot be tensors. Please provide input_fn.')

    if feed_fn is not None:
      raise ValueError('Can not provide both feed_fn and x or y.')
  else:
    if (x is not None) or (y is not None):
      raise ValueError('Can not provide both input_fn and x or y.')
    if batch_size is not None:
      raise ValueError('Can not provide both input_fn and batch_size.') 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:19,代码来源:estimator.py

示例2: _get_input_fn

# 需要导入模块: from tensorflow.contrib import framework [as 别名]
# 或者: from tensorflow.contrib.framework import is_tensor [as 别名]
def _get_input_fn(x, y, input_fn, feed_fn, batch_size, shuffle=False, epochs=1):
  """Make inputs into input and feed functions.

  Args:
    x: Numpy, Pandas or Dask matrix or iterable.
    y: Numpy, Pandas or Dask matrix or iterable.
    input_fn: Pre-defined input function for training data.
    feed_fn: Pre-defined data feeder function.
    batch_size: Size to split data into parts. Must be >= 1.
    shuffle: Whether to shuffle the inputs.
    epochs: Number of epochs to run.

  Returns:
    Data input and feeder function based on training data.

  Raises:
    ValueError: Only one of `(x & y)` or `input_fn` must be provided.
  """
  if input_fn is None:
    if x is None:
      raise ValueError('Either x or input_fn must be provided.')

    if contrib_framework.is_tensor(x) or (y is not None and
                                          contrib_framework.is_tensor(y)):
      raise ValueError('Inputs cannot be tensors. Please provide input_fn.')

    if feed_fn is not None:
      raise ValueError('Can not provide both feed_fn and x or y.')

    df = data_feeder.setup_train_data_feeder(x, y, n_classes=None,
                                             batch_size=batch_size,
                                             shuffle=shuffle,
                                             epochs=epochs)
    return df.input_builder, df.get_feed_dict_fn()

  if (x is not None) or (y is not None):
    raise ValueError('Can not provide both input_fn and x or y.')
  if batch_size is not None:
    raise ValueError('Can not provide both input_fn and batch_size.')

  return input_fn, feed_fn 
开发者ID:tobegit3hub,项目名称:deep_image_model,代码行数:43,代码来源:estimator.py

示例3: __init__

# 需要导入模块: from tensorflow.contrib import framework [as 别名]
# 或者: from tensorflow.contrib.framework import is_tensor [as 别名]
def __init__(self, args):
        self.args = args
        self.tf_args = [(i,a) for i,a in enumerate(args) if is_tensor(a)] 
开发者ID:cheind,项目名称:tf-matplotlib,代码行数:5,代码来源:meta.py

示例4: __init__

# 需要导入模块: from tensorflow.contrib import framework [as 别名]
# 或者: from tensorflow.contrib.framework import is_tensor [as 别名]
def __init__(self,
               dtype,
               is_continuous,
               is_reparameterized,
               validate_args,
               allow_nan_stats,
               parameters=None,
               graph_parents=None,
               name=None):
    """Constructs the `Distribution`.

    **This is a private method for subclass use.**

    Args:
      dtype: The type of the event samples. `None` implies no type-enforcement.
      is_continuous: Python boolean. If `True` this
        `Distribution` is continuous over its supported domain.
      is_reparameterized: Python boolean. If `True` this
        `Distribution` can be reparameterized in terms of some standard
        distribution with a function whose Jacobian is constant for the support
        of the standard distribution.
      validate_args: Python boolean.  Whether to validate input with asserts.
        If `validate_args` is `False`, and the inputs are invalid,
        correct behavior is not guaranteed.
      allow_nan_stats: Python boolean.  If `False`, raise an
        exception if a statistic (e.g., mean, mode) is undefined for any batch
        member. If True, batch members with valid parameters leading to
        undefined statistics will return `NaN` for this statistic.
      parameters: Python dictionary of parameters used to instantiate this
        `Distribution`.
      graph_parents: Python list of graph prerequisites of this `Distribution`.
      name: A name for this distribution. Default: subclass name.

    Raises:
      ValueError: if any member of graph_parents is `None` or not a `Tensor`.
    """
    graph_parents = [] if graph_parents is None else graph_parents
    for i, t in enumerate(graph_parents):
      if t is None or not contrib_framework.is_tensor(t):
        raise ValueError("Graph parent item %d is not a Tensor; %s." % (i, t))
    parameters = parameters or {}
    self._dtype = dtype
    self._is_continuous = is_continuous
    self._is_reparameterized = is_reparameterized
    self._allow_nan_stats = allow_nan_stats
    self._validate_args = validate_args
    self._parameters = parameters
    self._graph_parents = graph_parents
    self._name = name or type(self).__name__ 
开发者ID:abhisuri97,项目名称:auto-alt-text-lambda-api,代码行数:51,代码来源:distribution.py

示例5: __init__

# 需要导入模块: from tensorflow.contrib import framework [as 别名]
# 或者: from tensorflow.contrib.framework import is_tensor [as 别名]
def __init__(self,
               dtype,
               graph_parents=None,
               is_non_singular=None,
               is_self_adjoint=None,
               is_positive_definite=None,
               name=None):
    r"""Initialize the `LinearOperator`.

    **This is a private method for subclass use.**
    **Subclasses should copy-paste this `__init__` documentation.**

    Args:
      dtype: The type of the this `LinearOperator`.  Arguments to `apply` and
        `solve` will have to be this type.
      graph_parents: Python list of graph prerequisites of this `LinearOperator`
        Typically tensors that are passed during initialization.
      is_non_singular:  Expect that this operator is non-singular.
      is_self_adjoint:  Expect that this operator is equal to its hermitian
        transpose.  If `dtype` is real, this is equivalent to being symmetric.
      is_positive_definite:  Expect that this operator is positive definite,
        meaning the real part of all eigenvalues is positive.  We do not require
        the operator to be self-adjoint to be positive-definite.  See:
        https://en.wikipedia.org/wiki/Positive-definite_matrix\
            #Extension_for_non_symmetric_matrices
      name: A name for this `LinearOperator`.

    Raises:
      ValueError: if any member of graph_parents is `None` or not a `Tensor`.
    """
    # Check and auto-set flags.
    if is_positive_definite:
      if is_non_singular is False:
        raise ValueError("A positive definite matrix is always non-singular.")
      is_non_singular = True

    graph_parents = [] if graph_parents is None else graph_parents
    for i, t in enumerate(graph_parents):
      if t is None or not contrib_framework.is_tensor(t):
        raise ValueError("Graph parent item %d is not a Tensor; %s." % (i, t))
    self._dtype = dtype
    self._graph_parents = graph_parents
    self._is_non_singular = is_non_singular
    self._is_self_adjoint = is_self_adjoint
    self._is_positive_definite = is_positive_definite
    self._name = name or type(self).__name__

    # We will cache some values to avoid repeatedly adding shape
    # manipulation ops to the graph.  Cleaner.
    self._cached_shape_dynamic = None
    self._cached_batch_shape_dynamic = None
    self._cached_domain_dimension_dynamic = None
    self._cached_range_dimension_dynamic = None
    self._cached_tensor_rank_dynamic = None 
开发者ID:abhisuri97,项目名称:auto-alt-text-lambda-api,代码行数:56,代码来源:linear_operator.py


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