Как добавить Transformer слой в модель TensorFlow?

Не могу добавить Transformer-слой в свою NLP-модель. Архитектура модели:

model = tf.keras.models.Sequential([
    tf.keras.layers.Embedding(total_words, 100, input_length=None, trainable=True),
    tf.keras.layers.Bidirectional(tf.keras.layers.LSTM(128, return_sequences=True)),
    tf.keras.layers.Dropout(0.1),
    tf.keras.layers.BatchNormalization(),
    tf.keras.layers.Bidirectional(tf.keras.layers.LSTM(128, return_sequences=True)),
    tf.keras.layers.Dropout(0.1),
    tf.keras.layers.BatchNormalization(),
    tf.keras.layers.Bidirectional(tf.keras.layers.LSTM(128, return_sequences=True)),
    tf.keras.layers.Dropout(0.1),
    tf.keras.layers.BatchNormalization(),
    tf.keras.layers.Bidirectional(tf.keras.layers.LSTM(128, return_sequences=False)),
    tf.keras.layers.Dropout(0.1),
    tf.keras.layers.BatchNormalization(),
    tf.keras.layers.Dense(total_words, activation='softmax')
]) 

Вот как выглядит model summary:

embedding_1 (Embedding)     (None, None, 100)         700       
                                                                 
 bidirectional_4 (Bidirecti  (None, None, 256)         234496    
 onal)                                                           
                                                                 
 dropout_4 (Dropout)         (None, None, 256)         0         
                                                                 
 batch_normalization_4 (Bat  (None, None, 256)         1024      
 chNormalization)                                                
                                                                 
 bidirectional_5 (Bidirecti  (None, None, 256)         394240    
 onal)                                                           
                                                                 
 dropout_5 (Dropout)         (None, None, 256)         0         
                                                                 
 batch_normalization_5 (Bat  (None, None, 256)         1024      
 chNormalization)                                                
                                                                 
 bidirectional_6 (Bidirecti  (None, None, 256)         394240    
 onal)                                                           
                                                                 
 dropout_6 (Dropout)         (None, None, 256)         0         
                                                                 
 batch_normalization_6 (Bat  (None, None, 256)         1024      
 chNormalization)                                                
                                                                 
 bidirectional_7 (Bidirecti  (None, 256)               394240    
 onal)                                                           
                                                                 
 dropout_7 (Dropout)         (None, 256)               0         
                                                                 
 batch_normalization_7 (Bat  (None, 256)               1024      
 chNormalization)                                                
                                                                 
 dense_1 (Dense) 

Ответы (0 шт):