本文整理汇总了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
示例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,)