숫자를 텍스트로 쓰려면 tf.as_string
을 사용하는 것이 좋습니다. 당신이 정말로 이진 문자열로 작성하려면, 그러나, 그것은 가능한 것으로 판명 : 나를 위해
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]) # Shape information is lost
with tf.Session() as session:
before, after = session.run([starting_tensor, back_to_tensor])
print(before - after)
이 모두 0의 배열을 인쇄합니다. 파이썬 3 작업들을 위해
작동합니다! 감사! –