ValueError: Dimensions must be equal, but are 200 and 356 for 'rnn/while/rnn/multi_rnn_cell/cell_0/c
1165 ワード
次のエラーが発生しました.
ValueError: Dimensions must be equal, but are 200 and 356 for 'rnn/while/rnn/multi_rnn_cell/cell_0/cell_0/basic_lstm_cell/MatMul_1' (op: 'MatMul') with input shapes: [128,200], [356,400].
コードは次のとおりです.
最初はcell=tfと思った.nn.rnn_cell.MultiRNNcell([lstm_cell]*config.num_layers)をcell=tfに変更する.nn.rnn_cell.MultiRNNcell([lstm_cell for_in range(config.num_layers)])でいいのですが、実はそうではなくself.sizeの大きさはembedding sizeの大きさにすればよい
参照先:
https://stackoverflow.com/questions/48792485/value-error-from-tf-nn-dynamic-rnn-dimensions-must-be-equal
ValueError: Dimensions must be equal, but are 200 and 356 for 'rnn/while/rnn/multi_rnn_cell/cell_0/cell_0/basic_lstm_cell/MatMul_1' (op: 'MatMul') with input shapes: [128,200], [356,400].
コードは次のとおりです.
lstm_cell = tf.nn.rnn_cell.BasicLSTMCell(self.size, forget_bias=0.0)
lstm_cell = tf.nn.rnn_cell.DropoutWrapper(lstm_cell, output_keep_prob=self.keep_prob)
# cell = tf.nn.rnn_cell.MultiRNNCell([lstm_cell] * config.num_layers)
cell = tf.nn.rnn_cell.MultiRNNCell([lstm_cell for _ in range(config.num_layers)])
self.initial_state = cell.zero_state(self.batch_size, tf.float32)
outputs_lstm, _ = tf.nn.dynamic_rnn(cell, inputs, initial_state=self.initial_state,
sequence_length=self.input_length)
最初はcell=tfと思った.nn.rnn_cell.MultiRNNcell([lstm_cell]*config.num_layers)をcell=tfに変更する.nn.rnn_cell.MultiRNNcell([lstm_cell for_in range(config.num_layers)])でいいのですが、実はそうではなくself.sizeの大きさはembedding sizeの大きさにすればよい
参照先:
https://stackoverflow.com/questions/48792485/value-error-from-tf-nn-dynamic-rnn-dimensions-must-be-equal