tf.contrib.data.ignore_errors
Stay organized with collections
Save and categorize content based on your preferences.
Creates a Dataset
from another Dataset
and silently ignores any errors. (deprecated)
tf.contrib.data.ignore_errors()
Use this transformation to produce a dataset that contains the same elements
as the input, but silently drops any elements that caused an error. For
example:
dataset = tf.data.Dataset.from_tensor_slices([1., 2., 0., 4.])
# Computing `tf.debugging.check_numerics(1. / 0.)` will raise an
InvalidArgumentError.
dataset = dataset.map(lambda x: tf.debugging.check_numerics(1. / x, "error"))
# Using `ignore_errors()` will drop the element that causes an error.
dataset =
dataset.apply(tf.data.experimental.ignore_errors()) # ==> { 1., 0.5, 0.2
}
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2020-10-01 UTC.
[null,null,["Last updated 2020-10-01 UTC."],[],[],null,["# tf.contrib.data.ignore_errors\n\n\u003cbr /\u003e\n\n|----------------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v1.15.0/tensorflow/contrib/data/python/ops/error_ops.py#L24-L49) |\n\nCreates a `Dataset` from another `Dataset` and silently ignores any errors. (deprecated) \n\n tf.contrib.data.ignore_errors()\n\n| **Warning:** THIS FUNCTION IS DEPRECATED. It will be removed in a future version. Instructions for updating: Use [`tf.data.experimental.ignore_errors()`](../../../tf/data/experimental/ignore_errors).\n\nUse this transformation to produce a dataset that contains the same elements\nas the input, but silently drops any elements that caused an error. For\nexample: \n\n dataset = tf.data.Dataset.from_tensor_slices([1., 2., 0., 4.])\n\n # Computing `tf.debugging.check_numerics(1. / 0.)` will raise an\n InvalidArgumentError.\n dataset = dataset.map(lambda x: tf.debugging.check_numerics(1. / x, \"error\"))\n\n # Using `ignore_errors()` will drop the element that causes an error.\n dataset =\n dataset.apply(tf.data.experimental.ignore_errors()) # ==\u003e { 1., 0.5, 0.2\n }\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|---|---|\n| A `Dataset` transformation function, which can be passed to [`tf.data.Dataset.apply`](../../../tf/data/Dataset#apply). ||\n\n\u003cbr /\u003e"]]