MCPcopy Create free account
hub / github.com/tensorflow/models / distribute_dataset

Method distribute_dataset

official/core/base_trainer.py:98–123  ·  view source on GitHub ↗

A utility function to help create a `tf.distribute.DistributedDataset`. Args: dataset_or_fn: A instance of `tf.data.Dataset`, or a "dataset function" returning a `tf.data.Dataset`. If it is a function, it may optionally have an argument named `input_context` which will be

(self, dataset_or_fn, *args, **kwargs)

Source from the content-addressed store, hash-verified

96 return eval_loop_fn
97
98 def distribute_dataset(self, dataset_or_fn, *args, **kwargs):
99 """A utility function to help create a `tf.distribute.DistributedDataset`.
100
101 Args:
102 dataset_or_fn: A instance of `tf.data.Dataset`, or a "dataset function"
103 returning a `tf.data.Dataset`. If it is a function, it may optionally
104 have an argument named `input_context` which will be passed a
105 `tf.distribute.InputContext` instance.
106 *args: Any positional arguments to pass through to `dataset_or_fn`.
107 **kwargs: Any keyword arguments to pass through to `dataset_or_fn`.
108
109 Returns:
110 A distributed Dataset.
111 """
112 if getattr(self, "_is_async", False):
113 per_worker_dataset_fn = functools.partial(
114 orbit.utils.make_distributed_dataset, self._strategy, dataset_or_fn,
115 *args, **kwargs)
116 per_worker_dataset_fn = tf.function(per_worker_dataset_fn)
117
118 return self.coordinator_for_async().create_per_worker_dataset(
119 per_worker_dataset_fn
120 )
121 else:
122 return orbit.utils.make_distributed_dataset(self._strategy, dataset_or_fn,
123 *args, **kwargs)
124
125
126def get_runtime_options(config: ExperimentConfig):

Callers 2

__init__Method · 0.80
__init__Method · 0.80

Calls 2

coordinator_for_asyncMethod · 0.95
functionMethod · 0.80

Tested by 1

__init__Method · 0.64