我知道
def build_cell(lstm_size):
lstm = tf.contrib.rnn.BasicLSTMCell(lstm_size)
return drop
cell = tf.contrib.rnn.MultiRNNCell([build_cell(128) for _ in range(2)])
initial_state = cell.zero_state(batch_size, tf.float32)
此initial_state
可以作为dynamic_rnn
的初始状态传递。但是,如果在上述代码的末尾添加initial_state=tf.identity(initial_state, 'initial_state')
,则initial_state
将成为张量,并且将initial_state
传递给dynamic_rnn
不再合法。有没有一种方法可以解决此问题,而不是删除identity
语句?