ValueError: Dimensions must be equal, but are 16 and 28 for 'seq2seq/decoder/train/decoder/while/BasicDecoderStep/lstm_cell/MatMul_4' (op: 'MatMul') with input shapes: [2,16], [28,40]
运行tensorflow代码出错,原因是把tf.contrib.seq2seq.BasicDecoder这个函数的cell类搞错了,因为之前已经对decoder_cell这个类进行了重写,所以这里的cell类也需要改变,但是这个错误发生的原因也有很多,这里是由于类的重写导致前后类不一致,
self.decoder_cell = tf.nn.rnn_cell.LSTMCell(_num_units)
self.decoder_cell = tf.nn.rnn_cell.LSTMCell(_num_units)
with tf.variable_scope("MC"):
mc_cell = NewMTAWrapper(self.decoder_cell, topic_embedded,self.history_memory,
self.v, self.uf, self.query_layer,
self.memory_layer,ex_memory=self.memory,mask=masks)
rollout_decoder_MC = tf.contrib.seq2seq.BasicDecoder(
cell=self.decoder_cell, #should be mc_cell
helper=helper_MC,
initial_state=initial_state_MC,
output_layer=self.output_layer