ValueError:尺寸必须相等,但对于MatMul_1,尺寸应为53和150,输入形状为[?,53],[150,200]

时间:2020-03-09 15:56:05

标签: python tensorflow

我写了一些代码,将两个不同尺寸的向量发送到Bi-LSTM中,并连接输出,但出现错误。 这是我的代码:

        with tf.variable_scope("bi-lstm"):
            cell_bw = LSTMCell(self.hidden_dim)
            cell_fw = LSTMCell(self.hidden_dim)

            (output_fw_seq_e, output_bw_seq_e), _ = tf.nn.bidirectional_dynamic_rnn(
                cell_fw=cell_fw,
                cell_bw=cell_bw,
                inputs=self.word_embeddings,
                sequence_length=self.sequence_lengths,
                dtype=tf.float32)
            output_e = tf.concat([output_fw_seq_e, output_bw_seq_e], axis=-1)

            (output_fw_seq_d, output_bw_seq_d), _ = tf.nn.bidirectional_dynamic_rnn(
                cell_fw=cell_fw,
                cell_bw=cell_bw,
                inputs=self.features_dim,
                sequence_length=self.sequence_lengths,
                dtype=tf.float32)
            output_d = tf.concat([output_fw_seq_d, output_bw_seq_d], axis=-1)

            output = tf.concat([output_e, output_d], axis=-1)
            output = tf.nn.dropout(output, self.dropout_pl)

self.hidden_​​dim: 50dim;

self.word_embeddings :100dim;

self.features_dim :3dim;

请帮助

0 个答案:

没有答案