ConvLSTMCell用于文本分类

时间:2018-12-09 20:27:33

标签: tensorflow text-classification rnn

我正在尝试使用tf.contrib.rnn.ConvLSTMCell进行文本分类,但是在使用它时出现以下错误值:

ValueError: Conv Linear expects 3D, 4D or 5D arguments: [[None, 303], [None, 86, 1]]

我的代码是:

    with tf.name_scope('dynamic_rnn'):
        lstm_cell_fw = tf.contrib.rnn.ConvLSTMCell(
            conv_ndims= 1,
            input_shape= [self.max_sentence_len, self.embedding_dim],
            output_channels=1,
            kernel_shape=[1, 1],
            use_bias=True,
            skip_connection=False,
            forget_bias=1.0,
            initializers=None,
            name='conv_lstm_cell'

        )
        lstm_cell_bw = tf.contrib.rnn.ConvLSTMCell(
            conv_ndims= 1,
            input_shape= [self.max_sentence_len, self.embedding_dim],
            output_channels=1,
            kernel_shape=[1, 1],
            use_bias=True,
            skip_connection=False,
            forget_bias=1.0,
            initializers=None,
            name='conv_lstm_cell'

        )
        outputs, state, _ = tf.nn.static_bidirectional_rnn(
            lstm_cell_fw,
            lstm_cell_bw,
            tf.unstack(tf.transpose(inputs, perm=[1, 0, 2])),
            sequence_length=self.sentence_lens,
            dtype=tf.float32,
            scope=None
        )
        outputs = tf.reshape(tf.concat(outputs, 1), [-1, self.max_sentence_len, self.n_hidden * 2])
        batch_size = tf.shape(outputs)[0]

请,有人可以帮助我吗?我是这个领域的新手

0 个答案:

没有答案