I would recommend writing numbers as text using tf.as_string . However, if you really want to write them as a binary string, this is possible:
import tensorflow as tf with tf.Graph().as_default(): character_lookup = tf.constant([chr(i) for i in range(256)]) starting_dtype = tf.float32 starting_tensor = tf.random_normal(shape=[10, 10], stddev=1e5, dtype=starting_dtype) as_string = tf.reduce_join( tf.gather(character_lookup, tf.cast(tf.bitcast(starting_tensor, tf.uint8), tf.int32))) back_to_tensor = tf.reshape(tf.decode_raw(as_string, starting_dtype), [10, 10])
This for me prints an array of all zeros.
source share