'Access Tensorflow tensor value

I have a tensor with the following properties. I want to save the numpy = 1 but I don't know how to access this value. How do I do this?

test_labels[1]

<tf.Tensor: shape=(), dtype=int32, numpy=1>


Solution 1:[1]

You can use tf.print() to get the values of the tensor.

For Example:

a=tf.constant(1) #Output:<tf.Tensor: shape=(), dtype=int32, numpy=1>  

tf.print(a) #Output:1

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1