0
다음 코드 조각에 문제가 있습니다. obs_pattern
, obs_seq
및 obs_seq_s
은 예상되는 동작을 생성하지 않습니다. TensorFlow 1.2.1을 사용해 보았습니다. 나는 틀린 무언가가다는 것을 의심한다.대화 형 세션 eval 및 tf.random_uniform이 예상 출력을 생성하지 않습니다.
import tensorflow as tf
sess = tf.InteractiveSession()
seq_length = 5
num_bits = 4
obs_pattern_shape = [num_bits, seq_length]
obs_pattern = tf.cast(
tf.random_uniform(obs_pattern_shape, minval=0, maxval=2, seed=1234, dtype=tf.int32),
tf.float32)
print(obs_pattern.eval())
seq_length_zeros = tf.zeros([1, seq_length])
obs_seq = tf.concat([obs_pattern, seq_length_zeros], axis=0)
print(obs_seq.eval())
add_vec = tf.one_hot([num_bits], (num_bits + 1), on_value = 1.0, off_value=0.0, axis=0)
obs_seq_s = tf.concat([obs_seq, add_vec], axis=1)
print(obs_seq_s.eval())
sess.close()
obs_pattern obs_seq
[[ 1. 1. 0. 1. 1.]
[ 0. 1. 1. 0. 1.]
[ 1. 1. 1. 0. 0.]
[ 1. 1. 0. 1. 0.]
[ 0. 0. 0. 0. 0.]]
obs_seq_s
[[ 1. 0. 0. 0. 0. 0.]
[ 0. 0. 1. 0. 0. 0.]
[ 0. 1. 0. 0. 0. 0.]
[ 0. 1. 0. 0. 0. 0.]
[ 0. 0. 0. 0. 0. 1.]]
EDIT
[[ 1. 1. 1. 0. 0.]
[ 0. 0. 0. 1. 0.]
[ 0. 1. 1. 0. 0.]
[ 0. 1. 0. 0. 0.]]
: t 기준 내가 obs_pattern 변경 아래 그가 언급 그리고 내가
그것은 당신이 새로운 임의 유니폼을 다시 실행 obs_pattern 형성된 텐서에 SESS를 실행할 때마다 예상된다import numpy as np
arr = np.random.randint(2, size=(num_bits, seq_length))
obs_pattern = tf.convert_to_tensor(arr, dtype=tf.float32)
달콤한! 고마워. – flyingmadden