TensorFlow的‘Did you mean to set reuse=None in VarScope?’解决方法

                    elif self.rnn == 'bi_two_layers':
                        self.representation_size = self.rnn_size * 2
                        rnn_outputs, rnn_state = tf.nn.bidirectional_dynamic_rnn(rnn_cell_bi_fw,
                                                                                       rnn_cell_bi_bw,
                                                                                       sent,
                                                                                       # sequence_length=split_size,
                                                                                       parallel_iterations=64,
                                                                                       swap_memory=True,
                                                                                       dtype=tf.float32,
                                                                                       scope='layer_1')
                        rnn_outputs = tf.concat(rnn_outputs, -1)

                        rnn_outputs, rnn_state = tf.nn.bidirectional_dynamic_rnn(rnn_cell_bi_fw_two,
                                                                                       rnn_cell_bi_bw_two,
                                                                                       rnn_outputs,
                                                                                       # sequence_length=split_size,
                                                                                       parallel_iterations=64,
                                                                                       swap_memory=True,
                                                                                       dtype=tf.float32,
                                                                                       scope='layer_2')

                        if self.rnn_rep == 'final':
                            rnn_state = tf.concat(rnn_state, 1)
                            return rnn_state
                        elif self.rnn_rep == 'average':
                            rnn_outputs = tf.concat(rnn_outputs, -1)
                            rnn_outputs = tf.reduce_mean(rnn_outputs, 1)
                            return rnn_outputs
                        elif self.rnn_rep == 'max':
                            rnn_outputs = tf.concat(rnn_outputs, -1)
                            rnn_outputs = tf.reduce_max(rnn_outputs, 1)
                            return rnn_outputs

用scope来解决。

你可能感兴趣的:(自然语言处理)