diff options
author | 2017-10-02 10:10:46 -0700 | |
---|---|---|
committer | 2017-10-02 10:14:03 -0700 | |
commit | 3c00952c6680d77ee2f10def35fbc7cbd138aea3 (patch) | |
tree | 3190a25d664ae44081ac5e490bcb75fff6670934 | |
parent | bad531131e24046670468bc89f0b7b9c4e160ce4 (diff) |
[tf.data] More actionable error message when passing a list to `Dataset.zip()`.
PiperOrigin-RevId: 170716623
-rw-r--r-- | tensorflow/python/data/ops/dataset_ops.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/tensorflow/python/data/ops/dataset_ops.py b/tensorflow/python/data/ops/dataset_ops.py index 9bcc83e8c5..aaea0f5db0 100644 --- a/tensorflow/python/data/ops/dataset_ops.py +++ b/tensorflow/python/data/ops/dataset_ops.py @@ -933,6 +933,16 @@ class ZipDataset(Dataset): def __init__(self, datasets): """See `Dataset.zip()` for details.""" super(ZipDataset, self).__init__() + for ds in nest.flatten(datasets): + if not isinstance(ds, Dataset): + if isinstance(ds, list): + message = ("The argument to `Dataset.zip()` must be a nested " + "structure of `Dataset` objects. Nested structures do not " + "support Python lists; please use a tuple instead.") + else: + message = ("The argument to `Dataset.zip()` must be a nested " + "structure of `Dataset` objects.") + raise TypeError(message) self._datasets = datasets def _as_variant_tensor(self): |