具体的错误类型如下图所示
修改之前的代码是:
def blstm_layer(self, embedding_chars):
with tf.variable_scope('rnn_layer'):
cell_fw, cell_bw = self._bi_dir_rnn()
if self.num_layers > 1:
cell_fw = rnn.MultiRNNCell([cell_fw] * self.num_layers, state_is_tuple=True)
cell_bw = rnn.MultiRNNCell([cell_bw] * self.num_layers, state_is_tuple=True)
bedding_chars,
dtype=tf.float32)
outputs = tf.concat(outputs, axis=2)
return outputs
修改之后的代码是:
def blstm_layer(self, embedding_chars):
with tf.variable_scope('rnn_layer'):
cell_fw, cell_bw = self._bi_dir_rnn()
if self.num_layers > 1:
# cell_fw = rnn.MultiRNNCell([cell_fw] * self.num_layers, state_is_tuple=True)
# cell_bw = rnn.MultiRNNCell([cell_bw] * self.num_layers, state_is_tuple=True)
cell_fw = rnn.MultiRNNCell([self._bi_dir_rnn()[0] for _ in range(self.num_layers)], state_is_tuple=True)
cell_bw = rnn.MultiRNNCell([self._bi_dir_rnn()[1] for _ in range(self.num_layers)], state_is_tuple=True)
outputs, _ = tf.nn.bidirectional_dynamic_rnn(cell_fw, cell_bw, embedding_chars,
dtype=tf.float32)
outputs = tf.concat(outputs, axis=2)
return outputs
当代码修改成下面这样,则问题解决了,现在可以进行训练了