[英]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) . 我希望能够通过占位符将初始状态馈入网络,并且TensorFlow仅允许馈送数组或张量(而且我不知道如何创建zer初始状态元组)。 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? 但是
tf.nn.dynamic_rnn
函数需要一个大小为3的元组。在本文的答案中: 当state_is_tuple = True时,如何设置TensorFlow RNN状态?
is exposed a method to do this conversion but the function utilised l = tf.unpack(state_placeholder, axis=0)
doesn't exist anymore. 暴露了一种执行此转换的方法,但是使用的函数
l = tf.unpack(state_placeholder, axis=0)
不再存在。 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? 我如何执行从形状张量(num_layer,2,batch_size,hidden_layers)到占位符的转换,
tf.nn.dynamic_rnn
为tf.nn.dynamic_rnn可以接受的tf.nn.dynamic_rnn
作为initial_state参数?
tf.unpack got replaced with tf.unstack. tf.unpack被替换为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? tf.unstack似乎可以完成工作,但是
tf.nn.dynamic_rnn
仍然向我抛出错误消息: AttributeError: 'LSTMStateTuple' object has no attribute 'get_shape'
如果不是预期的LSTMStateTuple,那是什么?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.