私はこれをしようとしていた。複数の計算ステップにわたるtf.TensorArrayは覚えていますか?
動作しませんta = tf.TensorArray(tf.int32, size=3)
index = tf.placeholder(tf.int32)
value = tf.placeholder(tf.int32)
flow = tf.placeholder(tf.float32)
ta_new = tf.TensorArray(dtype=ta.dtype, handle=ta.handle, flow=flow)
write = ta_new.write(index, value).flow
read = ta_new.read(index)
f = 0
f = session.run(write, feed_dict={index: 0, value: 1, flow: f})
f = session.run(write, feed_dict={index: 1, value: 2, flow: f})
assert_equal(session.run(read, feed_dict={index: 0, flow: f}), 1)
assert_equal(session.run(read, feed_dict={index: 1, flow: f}), 2)
。エラーが表示されます:
Could not read from TensorArray index 0 because it has not yet been written to.
これを動作させる方法はありますか?
私が理解しているように、TensorArray.flow
は、tf.control_dependencies
の代替として使用され、おそらく勾配の流れが得られますか?私はスカラー自体に意味がないと思う。また、プレースホルダとしてはそれほど意味をなさないものとして使用すると思います。しかし、私はまだそれが動作することを期待していたでしょう。
TensorArray
でいくつかの計算ステップに値を格納することは可能でしょうか?何か別の選択肢はありますか?私は基本的にそれを必要とします。例えば。 tf.FIFOQueue
は私にランダムなインデックスアクセスを与えません。