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


Python dataset_ops.make_initializable_iterator方法代碼示例

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


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

示例1: dataset_initializer

# 需要導入模塊: from tensorflow.python.data.ops import dataset_ops [as 別名]
# 或者: from tensorflow.python.data.ops.dataset_ops import make_initializable_iterator [as 別名]
def dataset_initializer(self):
    """Returns the dataset's initializer.

    The initializer must be run before calling `features_and_labels`.
    """
    self._iterator = dataset_ops.make_initializable_iterator(self._dataset)
    return self._iterator.initializer 
開發者ID:ymcui,項目名稱:Chinese-XLNet,代碼行數:9,代碼來源:tpu_estimator.py

示例2: parse_input_fn_result

# 需要導入模塊: from tensorflow.python.data.ops import dataset_ops [as 別名]
# 或者: from tensorflow.python.data.ops.dataset_ops import make_initializable_iterator [as 別名]
def parse_input_fn_result(result):
  """Gets features, labels, and hooks from the result of an Estimator input_fn.

  Args:
    result: output of an input_fn to an estimator, which should be one of:
      * A 'tf.data.Dataset' object: Outputs of `Dataset` object must be a tuple
        (features, labels) with same constraints as below.
      * A tuple (features, labels): Where `features` is a `Tensor` or a
        dictionary of string feature name to `Tensor` and `labels` is a `Tensor`
        or a dictionary of string label name to `Tensor`. Both `features` and
        `labels` are consumed by `model_fn`. They should satisfy the expectation
        of `model_fn` from inputs.

  Returns:
    Tuple of features, labels, and input_hooks, where features are as described
    above, labels are as described above or None, and input_hooks are a list
    of SessionRunHooks to be included when running.

  Raises:
    ValueError: if the result is a list or tuple of length != 2.
  """
  input_hooks = []
  if isinstance(result, dataset_ops.DatasetV2):
    iterator = dataset_ops.make_initializable_iterator(result)
    input_hooks.append(_DatasetInitializerHook(iterator))
    result = iterator.get_next()
  return parse_iterator_result(result) + (input_hooks,) 
開發者ID:tensorflow,項目名稱:estimator,代碼行數:29,代碼來源:util.py


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