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


Python parsing_ops.parse_single_example方法代碼示例

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


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

示例1: decode

# 需要導入模塊: from tensorflow.python.ops import parsing_ops [as 別名]
# 或者: from tensorflow.python.ops.parsing_ops import parse_single_example [as 別名]
def decode(self, serialized_example, items=None):
    """Decodes the given serialized TF-example.

    Args:
      serialized_example: a serialized TF-example tensor.
      items: the list of items to decode. These must be a subset of the item
        keys in self._items_to_handlers. If `items` is left as None, then all
        of the items in self._items_to_handlers are decoded.

    Returns:
      the decoded items, a list of tensor.
    """
    example = parsing_ops.parse_single_example(serialized_example,
                                               self._keys_to_features)

    # Reshape non-sparse elements just once:
    for k in self._keys_to_features:
      v = self._keys_to_features[k]
      if isinstance(v, parsing_ops.FixedLenFeature):
        example[k] = array_ops.reshape(example[k], v.shape)

    if not items:
      items = self._items_to_handlers.keys()

    outputs = []
    for item in items:
      handler = self._items_to_handlers[item]
      keys_to_tensors = {key: example[key] for key in handler.keys}
      outputs.append(handler.tensors_to_item(keys_to_tensors))
    return outputs 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:32,代碼來源:tfexample_decoder.py

示例2: parse_single_example

# 需要導入模塊: from tensorflow.python.ops import parsing_ops [as 別名]
# 或者: from tensorflow.python.ops.parsing_ops import parse_single_example [as 別名]
def parse_single_example(serialized, features, name=None, example_names=None):
  """Parses a single `Example` proto.

  See tf.parse_single_example.

  Args:
    serialized: A scalar string Tensor or LabeledTensor, a single serialized
      Example.
    features: A `dict` mapping feature keys to `labeled_tensor.FixedLenFeature`
      values.
    name: A name for this operation (optional).
    example_names: (Optional) A scalar string Tensor, the associated name.

  Returns:
    A `dict` mapping feature keys to `LabeledTensor` values.

  Raises:
    ValueError: if any feature is invalid.
  """
  serialized = core.convert_to_labeled_tensor(serialized)
  unlabeled_features = _labeled_to_unlabeled_features(features)

  unlabeled_parsed = parsing_ops.parse_single_example(
      serialized.tensor, unlabeled_features, name, example_names)

  parsed = {}
  for name, parsed_feature in unlabeled_parsed.items():
    parsed[name] = core.LabeledTensor(parsed_feature, features[name].axes)

  return parsed 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:32,代碼來源:io_ops.py

示例3: decode

# 需要導入模塊: from tensorflow.python.ops import parsing_ops [as 別名]
# 或者: from tensorflow.python.ops.parsing_ops import parse_single_example [as 別名]
def decode(self, serialized_example, items=None):
    """Decodes the given serialized TF-example.

    Args:
      serialized_example: a serialized TF-example tensor.
      items: the list of items to decode. These must be a subset of the item
        keys in self._items_to_handlers. If `items` is left as None, then all
        of the items in self._items_to_handlers are decoded.

    Returns:
      the decoded items, a list of tensor.
    """
    example = parsing_ops.parse_single_example(serialized_example,
                                               self._keys_to_features)

    # Reshape non-sparse elements just once, adding the reshape ops in
    # deterministic order.
    for k in sorted(self._keys_to_features):
      v = self._keys_to_features[k]
      if isinstance(v, parsing_ops.FixedLenFeature):
        example[k] = array_ops.reshape(example[k], v.shape)

    if not items:
      items = self._items_to_handlers.keys()

    outputs = []
    for item in items:
      handler = self._items_to_handlers[item]
      keys_to_tensors = {key: example[key] for key in handler.keys}
      outputs.append(handler.tensors_to_item(keys_to_tensors))
    return outputs 
開發者ID:google-research,項目名稱:tf-slim,代碼行數:33,代碼來源:tfexample_decoder.py

示例4: decode

# 需要導入模塊: from tensorflow.python.ops import parsing_ops [as 別名]
# 或者: from tensorflow.python.ops.parsing_ops import parse_single_example [as 別名]
def decode(self, serialized_example, items=None):
    """Decodes the given serialized TF-example.

    Args:
      serialized_example: a serialized TF-example tensor.
      items: the list of items to decode. These must be a subset of the item
        keys in self._items_to_handlers. If `items` is left as None, then all
        of the items in self._items_to_handlers are decoded.

    Returns:
      the decoded items, a list of tensor.
    """
    example = parsing_ops.parse_single_example(
        serialized_example,
        self._keys_to_features)

    # Reshape non-sparse elements just once:
    for k in self._keys_to_features:
      v = self._keys_to_features[k]
      if isinstance(v, parsing_ops.FixedLenFeature):
        example[k] = array_ops.reshape(example[k], v.shape)

    if not items:
      items = self._items_to_handlers.keys()

    outputs = []
    for item in items:
      handler = self._items_to_handlers[item]
      keys_to_tensors = {key: example[key] for key in handler.keys}
      outputs.append(handler.tensors_to_item(keys_to_tensors))
    return outputs 
開發者ID:tobegit3hub,項目名稱:deep_image_model,代碼行數:33,代碼來源:tfexample_decoder.py


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