当前位置: 首页>>代码示例>>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;未经允许,请勿转载。