tensorflow中动态函数参数的类型错误

tensorflow中动态函数参数的类型错误,tensorflow,rnn,Tensorflow,Rnn,我在tensorflow中编写了这段代码,运行它后,我得到了这个错误 hidden_size = 1 batch_size = 1 seq_len = 3 feature_dim = 1 lstm_cell = tf.nn.rnn_cell.BasicLSTMCell(num_units=hidden_size) init_state = tf.placeholder_with_default( lstm_cell.zero_state(batch_size=batch_size, dt

我在tensorflow中编写了这段代码,运行它后,我得到了这个错误

hidden_size = 1
batch_size = 1
seq_len = 3
feature_dim = 1
lstm_cell = tf.nn.rnn_cell.BasicLSTMCell(num_units=hidden_size)
init_state = tf.placeholder_with_default(
    lstm_cell.zero_state(batch_size=batch_size, dtype=tf.float32), shape = [2, batch_size, hidden_size])
l = tf.Variable([seq_len])
v = tf.Variable(tf.random_normal(shape=[batch_size, seq_len, feature_dim], mean = 0, stddev = 0.01), name = 'v', trainable=True, dtype=tf.float32)
otuput, out_state = tf.nn.dynamic_rnn(lstm_cell, v, [seq_len], initial_state= init_state)
with tf.Session() as ses:
    ses.run(tf.global_variables_initializer())
问题是什么?

tf.nn.dynamic\u rnn参数初始状态应该是完全定义的张量,而不是占位符。用此行替换init_状态将修复错误

TypeError                                 Traceback (most recent call last)
<ipython-input-55-f105d2bb8ade> in <module>()
      8 l = tf.Variable([seq_len])
      9 v = tf.Variable(tf.random_normal(shape=[batch_size, seq_len, feature_dim], mean = 0, stddev = 0.01), name = 'v', trainable=True, dtype=tf.float32)
---> 10 otuput, out_state = tf.nn.dynamic_rnn(lstm_cell, v, [seq_len], initial_state= init_state)
     11 with tf.Session() as ses:
     12     ses.run(tf.global_variables_initializer())
.
.
.
TypeError: 'Tensor' object is not iterable.
...
init_state = lstm_cell.zero_state(batch_size=batch_size, dtype=tf.float32)
...