[null,null,["Last updated 2024-04-26 UTC."],[],[],null,["# tf.data.experimental.Counter\n\n\u003cbr /\u003e\n\n|-------------------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.16.1/tensorflow/python/data/experimental/ops/counter.py#L24-L59) |\n\nCreates a `Dataset` that counts from `start` in steps of size `step`. (deprecated) \n\n tf.data.experimental.Counter(\n start=0,\n step=1,\n dtype=../../../tf/dtypes#int64\n )\n\n### Used in the notebooks\n\n| Used in the guide | Used in the tutorials |\n|--------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------|\n| - [tf.data: Build TensorFlow input pipelines](https://www.tensorflow.org/guide/data) | - [Data augmentation](https://www.tensorflow.org/tutorials/images/data_augmentation) |\n\n| **Deprecated:** THIS FUNCTION IS DEPRECATED. It will be removed in a future version. Instructions for updating: Use [`tf.data.Dataset.counter(...)`](../../../tf/data/Dataset#counter) instead.\n\nUnlike [`tf.data.Dataset.range`](../../../tf/data/Dataset#range) which will stop at some ending number,\n`Counter` will produce elements indefinitely. \n\n dataset = tf.data.experimental.Counter().take(5)\n list(dataset.as_numpy_iterator())\n [0, 1, 2, 3, 4]\n dataset.element_spec\n TensorSpec(shape=(), dtype=tf.int64, name=None)\n dataset = tf.data.experimental.Counter(dtype=tf.int32)\n dataset.element_spec\n TensorSpec(shape=(), dtype=tf.int32, name=None)\n dataset = tf.data.experimental.Counter(start=2).take(5)\n list(dataset.as_numpy_iterator())\n [2, 3, 4, 5, 6]\n dataset = tf.data.experimental.Counter(start=2, step=5).take(5)\n list(dataset.as_numpy_iterator())\n [2, 7, 12, 17, 22]\n dataset = tf.data.experimental.Counter(start=10, step=-1).take(5)\n list(dataset.as_numpy_iterator())\n [10, 9, 8, 7, 6]\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|---------|----------------------------------------------------------------------------------------------|\n| `start` | (Optional.) The starting value for the counter. Defaults to 0. |\n| `step` | (Optional.) The step size for the counter. Defaults to 1. |\n| `dtype` | (Optional.) The data type for counter elements. Defaults to [`tf.int64`](../../../tf#int64). |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|---|---|\n| A `Dataset` of scalar `dtype` elements. ||\n\n\u003cbr /\u003e"]]