How to get int value from tf.size() without using session

Issue

label_one = [0,1,1,0,0,0,0]
tf.size(label_one) # returns a tensor 

How to get the value from the tensor without using session.

Solution

Assuming it’s a tensor’s length you want to derive using TensorFlow, following should work.

label_one = tf.constant([0,1,1,0,0,0,0])
print(label_one.shape[0])

Answered By – thushv89

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published