With the tf.data.Dataset.reduce()
method, we can get a shorthand transformation of all elements in the dataset using tf.data.Dataset. reduce ()
.
Syntax:
tf.data.Dataset.reduce ()
Return: Return combined single result after transformation.
Notes:
These examples will demonstrate the use of the new version of tensorflow 2.0, therefore, if you want to run these examples, run the following commands on the command line.
pip install tensorflow == 2.0.0-rc2
Example # 1:
In this example, we can see that using tf.data.Dataset.reduce ()
we can get a reduced transformation of all elements from the dataset.
|
Output:
15
Example # 2:
|
Output:
[15, 60]