Skip to content

Commit

Permalink
Fix dataset auto shard policy to ensure DistributingCloudTuner works …
Browse files Browse the repository at this point in the history
…for the latest TFX version

PiperOrigin-RevId: 367046579
  • Loading branch information
yinghsienwu authored and Tensorflow Cloud maintainers committed Apr 6, 2021
1 parent d509c23 commit 20c90e5
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/python/tensorflow_cloud/tuner/cloud_fit_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,14 @@ def _input_fn(file_pattern: List[Text],
reader=_gzip_reader_fn,
label_key=_transformed_name(label_key))

# If the input dataset is file-based but the number of files is less than
# the number of workers, an error will be raised. Turning off auto shard
# policy here so that Dataset will sharded by data instead of by file.
options = tf.data.Options()
options.experimental_distribute.auto_shard_policy = (
tf.data.experimental.AutoShardPolicy.DATA)
dataset = dataset.with_options(options)

return dataset


Expand Down

0 comments on commit 20c90e5

Please sign in to comment.