【发布时间】:2018-11-11 16:30:11
【问题描述】:
当(cell1, cell1) 用于MultiRNNCell 时,以下代码将失败:
import tensorflow as tf
cell1 = tf.contrib.rnn.BasicLSTMCell(128,reuse=False, name = "cell1")
cell2 = tf.contrib.rnn.BasicLSTMCell(128,reuse=False,name = "cell2")
multi = tf.contrib.rnn.MultiRNNCell([cell1, cell1] )
init = multi.zero_state(64, tf.float32)
output,state = multi(tf.ones([64,512]),init)
这段代码在哪里使用(cell1, cell2)。但是cell2 和cell1 是一样的:
import tensorflow as tf
cell1 = tf.contrib.rnn.BasicLSTMCell(128,reuse=False, name = "cell1")
cell2 = tf.contrib.rnn.BasicLSTMCell(128,reuse=False,name = "cell2")
multi = tf.contrib.rnn.MultiRNNCell([cell1, cell2] )
init = multi.zero_state(64, tf.float32)
output,state = multi(tf.ones([64,512]),init)
我可以知道这两个代码示例的区别吗?
一个错误是这样的:
ValueError:尺寸必须相等,但对于输入形状为 [64,256]、[640,512] 的“multi_rnn_cell/cell_0/cell1/MatMul_1”(操作:“MatMul”),尺寸必须是 256 和 640。
【问题讨论】:
标签: python tensorflow machine-learning lstm recurrent-neural-network