Created
June 28, 2020 17:05
-
-
Save snehalnair/948a8c8f9decd0af4a206b4fb4a641f9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def get_bilstm_lstm_model(): | |
| model = Sequential() | |
| # Add Embedding layer | |
| model.add(Embedding(input_dim=input_dim, output_dim=output_dim, input_length=input_length)) | |
| # Add bidirectional LSTM | |
| model.add(Bidirectional(LSTM(units=output_dim, return_sequences=True, dropout=0.2, recurrent_dropout=0.2), merge_mode = 'concat')) | |
| # Add LSTM | |
| model.add(LSTM(units=output_dim, return_sequences=True, dropout=0.5, recurrent_dropout=0.5)) | |
| # Add timeDistributed Layer | |
| model.add(TimeDistributed(Dense(n_tags, activation="relu"))) | |
| #Optimiser | |
| # adam = k.optimizers.Adam(lr=0.0005, beta_1=0.9, beta_2=0.999) | |
| # Compile model | |
| model.compile(loss='categorical_crossentropy', optimizer='adam', metrics=['accuracy']) | |
| model.summary() | |
| return model |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment