text_plain_output_1.png
from tensorflow.keras.layers import Bidirectional

from tensorflow.keras.layers import Conv1D

from tensorflow.keras.layers import Dense

from tensorflow.keras.layers import Embedding

from tensorflow.keras.layers import LSTM

from tensorflow.keras.layers import MaxPooling1D

import tensorflow as tf

class BiLSTM(tf.keras.Model):
    def __init__(self, NUM_WORDS, embedding_vector_length, num_of_class):
        super(BiLSTM, self).__init__()
        self.embedding = Embedding(input_dim=NUM_WORDS, output_dim=embedding_vector_length)
        self.BiLSTMl = Bidirectional(LSTM(100, return_sequences=True, recurrent_dropout=0.5))
        self.conv = Conv1D(filters=100, kernel_size=5, padding='same', activation='relu')
        self.MaxPool = MaxPooling1D(pool_size=2)
        self.BiLSTM2 = Bidirectional(LSTM(100, return_sequences=False, recurrent_dropout=0.5))
        self.dense = Dense(num_of_class, activation='sigmoid')
    def call(self, input_tensor):
        x = self.embedding(input_tensor)
        for _ in range(3):
            x = self.BiLSTMl(x)
            x = self.conv(x)
            x = self.MaxPool(x)
        x = self.BiLSTM2(x)
        x = self.dense(x)
        return x
model = BiLSTM(NUM_WORDS=22, embedding_vector_length=100, num_of_class=2)
model.build(input_shape=(None, 100))
model.summary()