I have created an OP in tensorflow where for some processing I need my data to be converted from tensor object to numpy array. I know we can use tf.eval() or sess.run to evaluate any tensor object. What I really want to know is, Is there any way to convert tensor to array without any session running, so in turn we avoid use of .eval() or .run().
Any help is highly appreciated!
def tensor_to_array(tensor1):
'''Convert tensor object to numpy array'''
array1 = SESS.run(tensor1) **#====== need to bypass this line**
return array1.astype("uint8")
def array_to_tensor(array):
'''Convert numpy array to tensor object'''
tensor_data = tf.convert_to_tensor(array, dtype=tf.float32)
return tensor_data