简体   繁体   中英

how to convert the tensor state of a rnn nework in a tuple

I want to be able to feed a initial state to a network via a placeholder and TensorFlow only allow array or tensor to be feed (And I don't know how to create a zer initiale state tuple) . But the tf.nn.dynamic_rnn function recquire a tuple of size 3. In the answer of this post: How do I set TensorFlow RNN state when state_is_tuple=True?

is exposed a method to do this conversion but the function utilised l = tf.unpack(state_placeholder, axis=0) doesn't exist anymore. How can i perform the conversion from a tensor of shape (num_layer,2,batch_size,hidden_layers) feed to a placeholder to a tupple acceptable by tf.nn.dynamic_rnn as a initial_state argument?

tf.unpack got replaced with tf.unstack. Can you use that instead?

tf.unstack seems to do the work but the tf.nn.dynamic_rnn still throw me an eror message : AttributeError: 'LSTMStateTuple' object has no attribute 'get_shape' If It's not an LSTMStateTuple that is expected what is it?

The total stack trace error is: 在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM