ValueError: Could not flatten dictionary: key Tensor("MultiRNNCellZeroState_1/BasicLSTMCellZeroState

今天晚上在做多个LSTM堆叠生成文字时,遇到了这个报错:ValueError: Could not flatten dictionary: key Tensor("MultiRNNCellZeroState_1/BasicLSTMCellZeroState/zeros:0", shape=(1, 128), dtype=float32) is not unique.

原来代码是这样的,

我自己研究了一下,觉得可能是这样的,(有可能理解不对):

intial_state的值:state是我们在第一行代码里初始化好的,它只有对应的一组值,然而对于LSTM的intial_state,却是包含三个状态门的一组值,它是一个list,分别对应着三种state,所以通过上面的方式建立feed_dict是不对的。

而正确的方式应该是:

通过循环迭代,分别取出state中三个门对应的状态。这样写就没问题了

猜你喜欢

转载自blog.csdn.net/orangefly0214/article/details/83317210