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


Python core._status_to_exception函数代码示例

本文整理汇总了Python中tensorflow.python.eager.core._status_to_exception函数的典型用法代码示例。如果您正苦于以下问题:Python _status_to_exception函数的具体用法?Python _status_to_exception怎么用?Python _status_to_exception使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: image_projective_transform

def image_projective_transform(images, transforms, interpolation, name=None):
  r"""Applies the given transform to each of the images.

  Input `image` is a `Tensor` in NHWC format (where the axes are image in batch,
  rows, columns, and channels. Input `transforms` is a num_images x 8 or 1 x 8
  matrix, where each row corresponds to a 3 x 3 projective transformation matrix,
  with the last entry assumed to be 1. If there is one row, the same
  transformation will be applied to all images.

  If one row of `transforms` is `[a0, a1, a2, b0, b1, b2, c0, c1]`, then it maps
  the *output* point `(x, y)` to a transformed *input* point
  `(x', y') = ((a0 x + a1 y + a2) / k, (b0 x + b1 y + b2) / k)`, where
  `k = c0 x + c1 y + 1`. If the transformed point lays outside of the input
  image, the output pixel is set to 0.

  Args:
    images: A `Tensor`. Must be one of the following types: `uint8`, `int32`, `int64`, `half`, `float32`, `float64`.
      4D `Tensor`, input image(s) in NHWC format.
    transforms: A `Tensor` of type `float32`.
      2D `Tensor`, projective transform(s) to apply to the image(s).
    interpolation: A `string`.
    name: A name for the operation (optional).

  Returns:
    A `Tensor`. Has the same type as `images`.
    4D `Tensor`, image(s) in NHWC format, generated by applying
    the `transforms` to the `images`. Satisfies the description above.
  """
  _ctx = _context._context
  if _ctx is None or not _ctx._eager_context.is_eager:
    interpolation = _execute.make_str(interpolation, "interpolation")
    _, _, _op = _op_def_lib._apply_op_helper(
        "ImageProjectiveTransform", images=images, transforms=transforms,
        interpolation=interpolation, name=name)
    _result = _op.outputs[:]
    _inputs_flat = _op.inputs
    _attrs = ("dtype", _op.get_attr("dtype"), "interpolation",
              _op.get_attr("interpolation"))
    _execute.record_gradient(
      "ImageProjectiveTransform", _inputs_flat, _attrs, _result, name)
    _result, = _result
    return _result

  else:
    try:
      _result = _pywrap_tensorflow.TFE_Py_FastPathExecute(
        _ctx._context_handle, _ctx._eager_context.device_name,
        "ImageProjectiveTransform", name, _ctx._post_execution_callbacks,
        images, transforms, "interpolation", interpolation)
      return _result
    except _core._FallbackException:
      return image_projective_transform_eager_fallback(
          images, transforms, interpolation=interpolation, name=name,
          ctx=_ctx)
    except _core._NotOkStatusException as e:
      if name is not None:
        message = e.message + " name: " + name
      else:
        message = e.message
      _six.raise_from(_core._status_to_exception(e.code, message), None)
开发者ID:whqkdhfh13,项目名称:sswp,代码行数:60,代码来源:gen_image_ops.py

示例2: ignite_dataset

def ignite_dataset(cache_name, host, port, local, part, page_size, schema, permutation, name=None):
  r"""IgniteDataset that allows to get data from Apache Ignite.

  Apache Ignite is a memory-centric distributed database, caching, and processing
  platform for transactional, analytical, and streaming workloads, delivering
  in-memory speeds at petabyte scale. This contrib package contains an
  integration between Apache Ignite and TensorFlow. The integration is based on
  tf.data from TensorFlow side and Binary Client Protocol from Apache Ignite side.
  It allows to use Apache Ignite as a datasource for neural network training,
  inference and all other computations supported by TensorFlow. Ignite Dataset
  is based on Apache Ignite Binary Client Protocol.

  Args:
    cache_name: A `Tensor` of type `string`. Ignite Cache Name.
    host: A `Tensor` of type `string`. Ignite Thin Client Host.
    port: A `Tensor` of type `int32`. Ignite Thin Client Port.
    local: A `Tensor` of type `bool`.
      Local flag that defines that data should be fetched from local host only.
    part: A `Tensor` of type `int32`. Partition data should be fetched from.
    page_size: A `Tensor` of type `int32`. Page size for Ignite Thin Client.
    schema: A `Tensor` of type `int32`.
      Internal structure that defines schema of cache objects.
    permutation: A `Tensor` of type `int32`.
      Internal structure that defines permutation of cache objects.
    name: A name for the operation (optional).

  Returns:
    A `Tensor` of type `variant`.
  """
  _ctx = _context._context
  if _ctx is None or not _ctx._eager_context.is_eager:
    _, _, _op = _op_def_lib._apply_op_helper(
        "IgniteDataset", cache_name=cache_name, host=host, port=port,
        local=local, part=part, page_size=page_size, schema=schema,
        permutation=permutation, name=name)
    _result = _op.outputs[:]
    _inputs_flat = _op.inputs
    _attrs = None
    _execute.record_gradient(
      "IgniteDataset", _inputs_flat, _attrs, _result, name)
    _result, = _result
    return _result

  else:
    try:
      _result = _pywrap_tensorflow.TFE_Py_FastPathExecute(
        _ctx._context_handle, _ctx._eager_context.device_name,
        "IgniteDataset", name, _ctx._post_execution_callbacks, cache_name,
        host, port, local, part, page_size, schema, permutation)
      return _result
    except _core._FallbackException:
      return ignite_dataset_eager_fallback(
          cache_name, host, port, local, part, page_size, schema, permutation,
          name=name, ctx=_ctx)
    except _core._NotOkStatusException as e:
      if name is not None:
        message = e.message + " name: " + name
      else:
        message = e.message
      _six.raise_from(_core._status_to_exception(e.code, message), None)
开发者ID:whqkdhfh13,项目名称:sswp,代码行数:60,代码来源:gen_dataset_ops.py

示例3: execute

def execute(op_name, num_outputs, inputs, attrs=None, name=None):
  """Execute a TensorFlow operation.

  Args:
    op_name: Name of the TensorFlow operation (see REGISTER_OP in C++ code) to
      execute.
    num_outputs: The number of outputs of the operation to fetch.
                 (Explicitly provided instead of being inferred for performance
                 reasons).
    inputs: A list of inputs to the operation. Each entry should be a Tensor, or
      a value which can be passed to the Tensor constructor to create one.
    attrs: A tuple with alternating string attr names and attr values for this
      operation.
    name: Customized name for the operation.

  Returns:
    None if there are no outputs, a single Tensor object if there is one output
    and a list of Tensor objects if there are multiple outputs.

  Raises:
    An exception on error.
  """
  ctx = context.get_default_context()
  # TODO(apassos) move this to convert_to_tensor
  inputs = [ag_core.getval(x) for x in inputs]
  # pylint: disable=protected-access
  input_handles = [c._handle for c in inputs]
  device_name = ctx.device_name
  try:
    outh = pywrap_tensorflow.TFE_Py_Execute(ctx._handle, device_name,
                                            str(op_name), input_handles, attrs,
                                            num_outputs)
    # pylint: enable=protected-access
  except core._NotOkStatusException as e:  # pylint: disable=protected-access
    if name is not None:
      message = e.message + " name: " + name
    else:
      message = e.message
    raise core._status_to_exception(e.code, message)  # pylint: disable=protected-access
  # pylint: enable=protected-access

  tensors = [tensor._tensor_from_handle(x) for x in outh]  # pylint: disable=protected-access
  # TODO(alive, cais): Use the execution callback mechanism.
  if core.active_trace() is not None:
    trace_name = name if name else op_name
    for t in tensors:
      # pylint: disable=protected-access
      core.active_trace().record_tensor(trace_name,
                                        ops.tensor_id(t),
                                        t._device_name(),
                                        t.shape.num_elements())
      # pylint: enable=protected-access

  # TODO(cais): Optimize this, perhaps by replacing this execute function with
  # a different one when there are execution callback(s).
  for callback in ctx.post_execution_callbacks:
    callback(op_name, name, attrs, inputs, tensors)

  return tensors
开发者ID:keveman,项目名称:tensorflow,代码行数:59,代码来源:execute.py

示例4: xla_launch

def xla_launch(constants, args, resources, Tresults, function, name=None):
  r"""XLA Launch Op. For use by the XLA JIT only.

  Args:
    constants: A list of `Tensor` objects.
    args: A list of `Tensor` objects.
    resources: A list of `Tensor` objects with type `resource`.
    Tresults: A list of `tf.DTypes`.
    function: A function decorated with @Defun.
    name: A name for the operation (optional).

  Returns:
    A list of `Tensor` objects of type `Tresults`.
  """
  _ctx = _context._context
  if _ctx is None or not _ctx._eager_context.is_eager:
    if not isinstance(resources, (list, tuple)):
      raise TypeError(
          "Expected list for 'resources' argument to "
          "'xla_launch' Op, not %r." % resources)
    _attr_Nresources = len(resources)
    if not isinstance(Tresults, (list, tuple)):
      raise TypeError(
          "Expected list for 'Tresults' argument to "
          "'xla_launch' Op, not %r." % Tresults)
    Tresults = [_execute.make_type(_t, "Tresults") for _t in Tresults]
    _, _, _op = _op_def_lib._apply_op_helper(
        "XlaLaunch", constants=constants, args=args, resources=resources,
        Tresults=Tresults, function=function, name=name)
    _result = _op.outputs[:]
    if not _result:
      return _op
    _inputs_flat = _op.inputs
    _attrs = ("Tconstants", _op.get_attr("Tconstants"), "Targs",
              _op.get_attr("Targs"), "Nresources", _op.get_attr("Nresources"),
              "Tresults", _op.get_attr("Tresults"), "function",
              _op.get_attr("function"))
    _execute.record_gradient(
      "XlaLaunch", _inputs_flat, _attrs, _result, name)
    return _result

  else:
    try:
      _result = _pywrap_tensorflow.TFE_Py_FastPathExecute(
        _ctx._context_handle, _ctx._eager_context.device_name, "XlaLaunch",
        name, _ctx._post_execution_callbacks, constants, args, resources,
        "Tresults", Tresults, "function", function)
      return _result
    except _core._FallbackException:
      return xla_launch_eager_fallback(
          constants, args, resources, Tresults=Tresults, function=function,
          name=name, ctx=_ctx)
    except _core._NotOkStatusException as e:
      if name is not None:
        message = e.message + " name: " + name
      else:
        message = e.message
      _six.raise_from(_core._status_to_exception(e.code, message), None)
开发者ID:whqkdhfh13,项目名称:sswp,代码行数:58,代码来源:xla_ops.py

示例5: kmeans_plus_plus_initialization

def kmeans_plus_plus_initialization(points, num_to_sample, seed, num_retries_per_sample, name=None):
  r"""Selects num_to_sample rows of input using the KMeans++ criterion.

  Rows of points are assumed to be input points. One row is selected at random.
  Subsequent rows are sampled with probability proportional to the squared L2
  distance from the nearest row selected thus far till num_to_sample rows have
  been sampled.

  Args:
    points: A `Tensor` of type `float32`.
      Matrix of shape (n, d). Rows are assumed to be input points.
    num_to_sample: A `Tensor` of type `int64`.
      Scalar. The number of rows to sample. This value must not be
      larger than n.
    seed: A `Tensor` of type `int64`.
      Scalar. Seed for initializing the random number generator.
    num_retries_per_sample: A `Tensor` of type `int64`.
      Scalar. For each row that is sampled, this parameter
      specifies the number of additional points to draw from the current
      distribution before selecting the best. If a negative value is specified, a
      heuristic is used to sample O(log(num_to_sample)) additional points.
    name: A name for the operation (optional).

  Returns:
    A `Tensor` of type `float32`.
    Matrix of shape (num_to_sample, d). The sampled rows.
  """
  _ctx = _context._context
  if _ctx is None or not _ctx._eager_context.is_eager:
    _, _, _op = _op_def_lib._apply_op_helper(
        "KmeansPlusPlusInitialization", points=points,
        num_to_sample=num_to_sample, seed=seed,
        num_retries_per_sample=num_retries_per_sample, name=name)
    _result = _op.outputs[:]
    _inputs_flat = _op.inputs
    _attrs = None
    _execute.record_gradient(
      "KmeansPlusPlusInitialization", _inputs_flat, _attrs, _result, name)
    _result, = _result
    return _result

  else:
    try:
      _result = _pywrap_tensorflow.TFE_Py_FastPathExecute(
        _ctx._context_handle, _ctx._eager_context.device_name,
        "KmeansPlusPlusInitialization", name, _ctx._post_execution_callbacks,
        points, num_to_sample, seed, num_retries_per_sample)
      return _result
    except _core._FallbackException:
      return kmeans_plus_plus_initialization_eager_fallback(
          points, num_to_sample, seed, num_retries_per_sample, name=name,
          ctx=_ctx)
    except _core._NotOkStatusException as e:
      if name is not None:
        message = e.message + " name: " + name
      else:
        message = e.message
      _six.raise_from(_core._status_to_exception(e.code, message), None)
开发者ID:whqkdhfh13,项目名称:sswp,代码行数:58,代码来源:gen_clustering_ops.py

示例6: range_decode

def range_decode(encoded, shape, cdf, precision, name=None):
  r"""Decodes a range-coded `code` into an int32 tensor of shape `shape`.

  This is the reverse op of RangeEncode. The shape of the tensor that was encoded
  should be known by the caller.

  Implementation notes:

  - If wrong input was given (e.g., corrupt `encoded` string, or `cdf` or
  `precision` do not match encoder), the decode is unsuccessful. Because of
  potential performance issues, the decoder does not return error status.

  Args:
    encoded: A `Tensor` of type `string`.
      A scalar string tensor from RangeEncode.
    shape: A `Tensor` of type `int32`.
      An int32 1-D tensor representing the shape of the data encoded by
      RangeEncode.
    cdf: A `Tensor` of type `int32`.
    precision: An `int` that is `>= 1`.
      The number of bits for probability quantization. Must be <= 16, and
      must match the precision used by RangeEncode that produced `encoded`.
    name: A name for the operation (optional).

  Returns:
    A `Tensor` of type `int16`. An int16 tensor with shape equal to `shape`.
  """
  _ctx = _context._context
  if _ctx is None or not _ctx._eager_context.is_eager:
    precision = _execute.make_int(precision, "precision")
    _, _, _op = _op_def_lib._apply_op_helper(
        "RangeDecode", encoded=encoded, shape=shape, cdf=cdf,
        precision=precision, name=name)
    _result = _op.outputs[:]
    _inputs_flat = _op.inputs
    _attrs = ("precision", _op.get_attr("precision"))
    _execute.record_gradient(
      "RangeDecode", _inputs_flat, _attrs, _result, name)
    _result, = _result
    return _result

  else:
    try:
      _result = _pywrap_tensorflow.TFE_Py_FastPathExecute(
        _ctx._context_handle, _ctx._eager_context.device_name, "RangeDecode",
        name, _ctx._post_execution_callbacks, encoded, shape, cdf,
        "precision", precision)
      return _result
    except _core._FallbackException:
      return range_decode_eager_fallback(
          encoded, shape, cdf, precision=precision, name=name, ctx=_ctx)
    except _core._NotOkStatusException as e:
      if name is not None:
        message = e.message + " name: " + name
      else:
        message = e.message
      _six.raise_from(_core._status_to_exception(e.code, message), None)
开发者ID:whqkdhfh13,项目名称:sswp,代码行数:57,代码来源:gen_coder_ops.py

示例7: nearest_neighbors

def nearest_neighbors(points, centers, k, name=None):
  r"""Selects the k nearest centers for each point.

  Rows of points are assumed to be input points. Rows of centers are assumed to be
  the list of candidate centers. For each point, the k centers that have least L2
  distance to it are computed.

  Args:
    points: A `Tensor` of type `float32`.
      Matrix of shape (n, d). Rows are assumed to be input points.
    centers: A `Tensor` of type `float32`.
      Matrix of shape (m, d). Rows are assumed to be centers.
    k: A `Tensor` of type `int64`.
      Scalar. Number of nearest centers to return for each point. If k is larger
      than m, then only m centers are returned.
    name: A name for the operation (optional).

  Returns:
    A tuple of `Tensor` objects (nearest_center_indices, nearest_center_distances).

    nearest_center_indices: A `Tensor` of type `int64`. Matrix of shape (n, min(m, k)). Each row contains the
      indices of the centers closest to the corresponding point, ordered by
      increasing distance.
    nearest_center_distances: A `Tensor` of type `float32`. Matrix of shape (n, min(m, k)). Each row contains the
      squared L2 distance to the corresponding center in nearest_center_indices.
  """
  _ctx = _context._context
  if _ctx is None or not _ctx._eager_context.is_eager:
    _, _, _op = _op_def_lib._apply_op_helper(
        "NearestNeighbors", points=points, centers=centers, k=k, name=name)
    _result = _op.outputs[:]
    _inputs_flat = _op.inputs
    _attrs = None
    _execute.record_gradient(
      "NearestNeighbors", _inputs_flat, _attrs, _result, name)
    _result = _NearestNeighborsOutput._make(_result)
    return _result

  else:
    try:
      _result = _pywrap_tensorflow.TFE_Py_FastPathExecute(
        _ctx._context_handle, _ctx._eager_context.device_name,
        "NearestNeighbors", name, _ctx._post_execution_callbacks, points,
        centers, k)
      _result = _NearestNeighborsOutput._make(_result)
      return _result
    except _core._FallbackException:
      return nearest_neighbors_eager_fallback(
          points, centers, k, name=name, ctx=_ctx)
    except _core._NotOkStatusException as e:
      if name is not None:
        message = e.message + " name: " + name
      else:
        message = e.message
      _six.raise_from(_core._status_to_exception(e.code, message), None)
开发者ID:whqkdhfh13,项目名称:sswp,代码行数:55,代码来源:gen_clustering_ops.py

示例8: image_connected_components

def image_connected_components(image, name=None):
  r"""Find the connected components of image(s).

  For each image (along the 0th axis), all connected components of adjacent pixels
  with the same non-zero value are detected and given unique ids.

  The returned `components` tensor has 0s for the zero pixels of `images`, and
  arbitrary nonzero ids for the connected components of nonzero values. Ids are
  unique across all of the images, and are in row-major order by the first pixel
  in the component.

  Uses union-find with union by rank but not path compression, giving a runtime of
  `O(n log n)`. See:
      https://en.wikipedia.org/wiki/Disjoint-set_data_structure#Time_Complexity

  Args:
    image: A `Tensor`. Must be one of the following types: `int64`, `int32`, `uint16`, `int16`, `uint8`, `int8`, `half`, `float32`, `float64`, `bool`, `string`.
      Image(s) with shape (N, H, W).
    name: A name for the operation (optional).

  Returns:
    A `Tensor` of type `int64`.
    Component ids for each pixel in "image". Same shape as "image". Zero
    pixels all have an output of 0, and all components of adjacent pixels with
    the same value are given consecutive ids, starting from 1.
  """
  _ctx = _context._context
  if _ctx is None or not _ctx._eager_context.is_eager:
    _, _, _op = _op_def_lib._apply_op_helper(
        "ImageConnectedComponents", image=image, name=name)
    _result = _op.outputs[:]
    _inputs_flat = _op.inputs
    _attrs = ("dtype", _op.get_attr("dtype"))
    _execute.record_gradient(
      "ImageConnectedComponents", _inputs_flat, _attrs, _result, name)
    _result, = _result
    return _result

  else:
    try:
      _result = _pywrap_tensorflow.TFE_Py_FastPathExecute(
        _ctx._context_handle, _ctx._eager_context.device_name,
        "ImageConnectedComponents", name, _ctx._post_execution_callbacks,
        image)
      return _result
    except _core._FallbackException:
      return image_connected_components_eager_fallback(
          image, name=name, ctx=_ctx)
    except _core._NotOkStatusException as e:
      if name is not None:
        message = e.message + " name: " + name
      else:
        message = e.message
      _six.raise_from(_core._status_to_exception(e.code, message), None)
开发者ID:whqkdhfh13,项目名称:sswp,代码行数:54,代码来源:gen_image_ops.py

示例9: _create_tensor

def _create_tensor(value, device=None, dtype=None):
  ctx = context.context()
  if device is None:
    device = ctx.device_name
  if dtype is not None:
    dtype = dtype.as_datatype_enum
  try:
    return ops.EagerTensor(
        value, context=ctx._handle, device=device, dtype=dtype)
  except core._NotOkStatusException as e:  # pylint: disable=protected-access
    raise core._status_to_exception(e.code, e.message)
开发者ID:marcomarchesi,项目名称:tensorflow,代码行数:11,代码来源:tensor_test.py

示例10: tree_ensemble_used_handlers

def tree_ensemble_used_handlers(tree_ensemble_handle, stamp_token, num_all_handlers, name=None):
  r"""Returns the mask of used handlers along with the number of non-zero elements in

  this mask. Used in feature selection.

  Args:
    tree_ensemble_handle: A `Tensor` of type `resource`.
      Handle to the tree ensemble.
    stamp_token: A `Tensor` of type `int64`.
      Token to use as the new value of the resource stamp.
    num_all_handlers: An `int` that is `>= 0`.
    name: A name for the operation (optional).

  Returns:
    A tuple of `Tensor` objects (num_used_handlers, used_handlers_mask).

    num_used_handlers: A `Tensor` of type `int64`. number of feature column handlers used in the model.
    used_handlers_mask: A `Tensor` of type `bool`. A boolean vector of showing which handlers are used in the
      model.
  """
  _ctx = _context._context
  if _ctx is None or not _ctx._eager_context.is_eager:
    num_all_handlers = _execute.make_int(num_all_handlers, "num_all_handlers")
    _, _, _op = _op_def_lib._apply_op_helper(
        "TreeEnsembleUsedHandlers", tree_ensemble_handle=tree_ensemble_handle,
        stamp_token=stamp_token, num_all_handlers=num_all_handlers, name=name)
    _result = _op.outputs[:]
    _inputs_flat = _op.inputs
    _attrs = ("num_all_handlers", _op.get_attr("num_all_handlers"))
    _execute.record_gradient(
      "TreeEnsembleUsedHandlers", _inputs_flat, _attrs, _result, name)
    _result = _TreeEnsembleUsedHandlersOutput._make(_result)
    return _result

  else:
    try:
      _result = _pywrap_tensorflow.TFE_Py_FastPathExecute(
        _ctx._context_handle, _ctx._eager_context.device_name,
        "TreeEnsembleUsedHandlers", name, _ctx._post_execution_callbacks,
        tree_ensemble_handle, stamp_token, "num_all_handlers",
        num_all_handlers)
      _result = _TreeEnsembleUsedHandlersOutput._make(_result)
      return _result
    except _core._FallbackException:
      return tree_ensemble_used_handlers_eager_fallback(
          tree_ensemble_handle, stamp_token,
          num_all_handlers=num_all_handlers, name=name, ctx=_ctx)
    except _core._NotOkStatusException as e:
      if name is not None:
        message = e.message + " name: " + name
      else:
        message = e.message
      _six.raise_from(_core._status_to_exception(e.code, message), None)
开发者ID:whqkdhfh13,项目名称:sswp,代码行数:53,代码来源:gen_model_ops.py

示例11: pmf_to_quantized_cdf

def pmf_to_quantized_cdf(pmf, precision, name=None):
  r"""Converts PMF to quantized CDF. This op uses floating-point operations

  internally. Therefore the quantized output may not be consistent across multiple
  platforms. For entropy encoders and decoders to have the same quantized CDF on
  different platforms, the quantized CDF should be produced once and saved, then
  the saved quantized CDF should be used everywhere.

  After quantization, if PMF does not sum to 2^precision, then some values of PMF
  are increased or decreased to adjust the sum to equal to 2^precision.

  Note that the input PMF is pre-quantization. The input PMF is not normalized
  by this op prior to quantization. Therefore the user is responsible for
  normalizing PMF if necessary.

  Args:
    pmf: A `Tensor` of type `float32`.
    precision: An `int` that is `>= 1`.
    name: A name for the operation (optional).

  Returns:
    A `Tensor` of type `int32`.
  """
  _ctx = _context._context
  if _ctx is None or not _ctx._eager_context.is_eager:
    precision = _execute.make_int(precision, "precision")
    _, _, _op = _op_def_lib._apply_op_helper(
        "PmfToQuantizedCdf", pmf=pmf, precision=precision, name=name)
    _result = _op.outputs[:]
    _inputs_flat = _op.inputs
    _attrs = ("precision", _op.get_attr("precision"))
    _execute.record_gradient(
      "PmfToQuantizedCdf", _inputs_flat, _attrs, _result, name)
    _result, = _result
    return _result

  else:
    try:
      _result = _pywrap_tensorflow.TFE_Py_FastPathExecute(
        _ctx._context_handle, _ctx._eager_context.device_name,
        "PmfToQuantizedCdf", name, _ctx._post_execution_callbacks, pmf,
        "precision", precision)
      return _result
    except _core._FallbackException:
      return pmf_to_quantized_cdf_eager_fallback(
          pmf, precision=precision, name=name, ctx=_ctx)
    except _core._NotOkStatusException as e:
      if name is not None:
        message = e.message + " name: " + name
      else:
        message = e.message
      _six.raise_from(_core._status_to_exception(e.code, message), None)
开发者ID:whqkdhfh13,项目名称:sswp,代码行数:52,代码来源:gen_coder_ops.py

示例12: tree_ensemble_stats

def tree_ensemble_stats(tree_ensemble_handle, stamp_token, name=None):
  r"""Retrieves stats related to the tree ensemble.

  Args:
    tree_ensemble_handle: A `Tensor` of type `resource`.
      Handle to the ensemble variable.
    stamp_token: A `Tensor` of type `int64`.
      Stamp token for validating operation consistency.
    name: A name for the operation (optional).

  Returns:
    A tuple of `Tensor` objects (num_trees, num_layers, active_tree, active_layer, attempted_trees, attempted_layers).

    num_trees: A `Tensor` of type `int64`. Scalar indicating the number of finalized trees in the ensemble.
    num_layers: A `Tensor` of type `int64`. Scalar indicating the number of layers in the ensemble.
    active_tree: A `Tensor` of type `int64`. Scalar indicating the active tree being trained.
    active_layer: A `Tensor` of type `int64`. Scalar indicating the active layer being trained.
    attempted_trees: A `Tensor` of type `int64`.
    attempted_layers: A `Tensor` of type `int64`.
  """
  _ctx = _context._context
  if _ctx is None or not _ctx._eager_context.is_eager:
    _, _, _op = _op_def_lib._apply_op_helper(
        "TreeEnsembleStats", tree_ensemble_handle=tree_ensemble_handle,
        stamp_token=stamp_token, name=name)
    _result = _op.outputs[:]
    _inputs_flat = _op.inputs
    _attrs = None
    _execute.record_gradient(
      "TreeEnsembleStats", _inputs_flat, _attrs, _result, name)
    _result = _TreeEnsembleStatsOutput._make(_result)
    return _result

  else:
    try:
      _result = _pywrap_tensorflow.TFE_Py_FastPathExecute(
        _ctx._context_handle, _ctx._eager_context.device_name,
        "TreeEnsembleStats", name, _ctx._post_execution_callbacks,
        tree_ensemble_handle, stamp_token)
      _result = _TreeEnsembleStatsOutput._make(_result)
      return _result
    except _core._FallbackException:
      return tree_ensemble_stats_eager_fallback(
          tree_ensemble_handle, stamp_token, name=name, ctx=_ctx)
    except _core._NotOkStatusException as e:
      if name is not None:
        message = e.message + " name: " + name
      else:
        message = e.message
      _six.raise_from(_core._status_to_exception(e.code, message), None)
开发者ID:whqkdhfh13,项目名称:sswp,代码行数:50,代码来源:gen_training_ops.py

示例13: decision_tree_ensemble_resource_handle_op

def decision_tree_ensemble_resource_handle_op(container="", shared_name="", name=None):
  r"""TODO: add doc.

  Args:
    container: An optional `string`. Defaults to `""`.
    shared_name: An optional `string`. Defaults to `""`.
    name: A name for the operation (optional).

  Returns:
    A `Tensor` of type `resource`.
  """
  _ctx = _context._context
  if _ctx is None or not _ctx._eager_context.is_eager:
    if container is None:
      container = ""
    container = _execute.make_str(container, "container")
    if shared_name is None:
      shared_name = ""
    shared_name = _execute.make_str(shared_name, "shared_name")
    _, _, _op = _op_def_lib._apply_op_helper(
        "DecisionTreeEnsembleResourceHandleOp", container=container,
        shared_name=shared_name, name=name)
    _result = _op.outputs[:]
    _inputs_flat = _op.inputs
    _attrs = ("container", _op.get_attr("container"), "shared_name",
              _op.get_attr("shared_name"))
    _execute.record_gradient(
      "DecisionTreeEnsembleResourceHandleOp", _inputs_flat, _attrs, _result, name)
    _result, = _result
    return _result

  else:
    try:
      _result = _pywrap_tensorflow.TFE_Py_FastPathExecute(
        _ctx._context_handle, _ctx._eager_context.device_name,
        "DecisionTreeEnsembleResourceHandleOp", name,
        _ctx._post_execution_callbacks, "container", container, "shared_name",
        shared_name)
      return _result
    except _core._FallbackException:
      return decision_tree_ensemble_resource_handle_op_eager_fallback(
          container=container, shared_name=shared_name, name=name, ctx=_ctx)
    except _core._NotOkStatusException as e:
      if name is not None:
        message = e.message + " name: " + name
      else:
        message = e.message
      _six.raise_from(_core._status_to_exception(e.code, message), None)
开发者ID:whqkdhfh13,项目名称:sswp,代码行数:48,代码来源:gen_model_ops.py

示例14: kmc2_chain_initialization

def kmc2_chain_initialization(distances, seed, name=None):
  r"""Returns the index of a data point that should be added to the seed set.

  Entries in distances are assumed to be squared distances of candidate points to
  the already sampled centers in the seed set. The op constructs one Markov chain
  of the k-MC^2 algorithm and returns the index of one candidate point to be added
  as an additional cluster center.

  Args:
    distances: A `Tensor` of type `float32`.
      Vector with squared distances to the closest previously sampled
      cluster center for each candidate point.
    seed: A `Tensor` of type `int64`.
      Scalar. Seed for initializing the random number generator.
    name: A name for the operation (optional).

  Returns:
    A `Tensor` of type `int64`. Scalar with the index of the sampled point.
  """
  _ctx = _context._context
  if _ctx is None or not _ctx._eager_context.is_eager:
    _, _, _op = _op_def_lib._apply_op_helper(
        "KMC2ChainInitialization", distances=distances, seed=seed, name=name)
    _result = _op.outputs[:]
    _inputs_flat = _op.inputs
    _attrs = None
    _execute.record_gradient(
      "KMC2ChainInitialization", _inputs_flat, _attrs, _result, name)
    _result, = _result
    return _result

  else:
    try:
      _result = _pywrap_tensorflow.TFE_Py_FastPathExecute(
        _ctx._context_handle, _ctx._eager_context.device_name,
        "KMC2ChainInitialization", name, _ctx._post_execution_callbacks,
        distances, seed)
      return _result
    except _core._FallbackException:
      return kmc2_chain_initialization_eager_fallback(
          distances, seed, name=name, ctx=_ctx)
    except _core._NotOkStatusException as e:
      if name is not None:
        message = e.message + " name: " + name
      else:
        message = e.message
      _six.raise_from(_core._status_to_exception(e.code, message), None)
开发者ID:whqkdhfh13,项目名称:sswp,代码行数:47,代码来源:gen_clustering_ops.py

示例15: quick_execute

def quick_execute(op_name, num_outputs, inputs, attrs, ctx, name=None):
  """Execute a TensorFlow operation.

  Args:
    op_name: Name of the TensorFlow operation (see REGISTER_OP in C++ code) to
      execute.
    num_outputs: The number of outputs of the operation to fetch.
                 (Explicitly provided instead of being inferred for performance
                 reasons).
    inputs: A list of inputs to the operation. Each entry should be a Tensor, or
      a value which can be passed to the Tensor constructor to create one.
    attrs: A tuple with alternating string attr names and attr values for this
      operation.
    ctx: The value of context.context().
    name: Customized name for the operation.

  Returns:
    List of output Tensor objects. The list is empty if there are no outputs

  Raises:
    An exception on error.
  """
  device_name = ctx.device_name
  # pylint: disable=protected-access
  try:
    tensors = pywrap_tensorflow.TFE_Py_Execute(ctx._handle, device_name,
                                               op_name, inputs, attrs,
                                               num_outputs)
  except core._NotOkStatusException as e:
    if name is not None:
      message = e.message + " name: " + name
    else:
      message = e.message
    six.raise_from(core._status_to_exception(e.code, message), None)
  except TypeError as e:
    if any(ops._is_keras_symbolic_tensor(x) for x in inputs):
      if any(isinstance(x, ops.EagerTensor) for x in inputs):
        raise TypeError("You are attempting to mix computation of symbolic "
                        "Tensors (computation rooted at tf.keras.Input()) "
                        "and concrete values. This is not supported. "
                        "If you need this support, file an issue on the "
                        "TensorFlow GitHub repository.")
      raise core._SymbolicException
    raise e
  # pylint: enable=protected-access
  return tensors
开发者ID:JonathanRaiman,项目名称:tensorflow,代码行数:46,代码来源:execute.py


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