tf.reduce_min: Get Minimum Value Of A TensorFlow Tensor

tf.reduce_min - Use TensorFlow's reduce_min operation to get the minimum value of a TensorFlow Tensor

Type: FREE   By: Sebastian Gutierrez, Instructor Sebastian Gutierrez   Duration: 1:42   Technologies: TensorFlow, Python

Page Sections: Video  |  Code  |  Transcript

< > Code:

You must be a Member to view code

Access all courses and lessons, gain confidence and expertise, and learn how things work and how to use them.

    or   Log In


This video will show you how to use tf.reduce_min operation to get the minimum value of a TensorFlow tensor.

First, we import TensorFlow as tf.

import tensorflow as tf

Next, we print out what version of TensorFlow we are using.


We are using TensorFlow 1.10.0.

Let’s start out by creating our tensor with generated values pulled from a random uniform distribution.

random_uniform_example = tf.random_uniform(shape=[2, 3, 4], dtype="int32", minval=0, maxval=10)

You can see we’re using tf.random_uniform, the shape is going to be 2x3x4, the data type is int32, the min value is going to be 0, and the max value is going to be 10.

All of this is assigned to the Python variable random_uniform_example.

Let’s now print our random uniform tensor to see what we have.


We see that it’s a TensorFlow tensor, we see that TensorFlow gave it a name, we see the shape is 2x3x4, and the data type is int32.

Now that we have created our TensorFlow tensor, it’s time to run the computational graph.

We launch the graph in a session.

sess = tf.Session()

Then we initialize all the global variables in the graph.

Now, let’s print our random_uniform_example tensor within a TensorFlow session.


We can see that all of our numbers are integers, and from the visual inspection, it looks like no numbers are less than 0 and no numbers are bigger than 10.

Next, let’s programmatically get the minimum number found in our random_uniform_example tensor using tf.reduce_min operation.


We pass in our tensor, we run it within a TensorFlow session, and then we print the result.

And the value that we get is 0, which visually inspecting the result is what we would expect.

Perfect! We were able to use tf.reduce_min operation to get the minimum value of a TensorFlow tensor.

Back to TensorFlow Tutorial Lesson List