Created
May 29, 2020 07:49
-
-
Save AdroitAnandAI/966b5ce445b89e9f65d2e7e43d327fb5 to your computer and use it in GitHub Desktop.
Deep RNN Model Architecture
This file contains 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 deep_rnn_model(input_dim, units, recur_layers, output_dim=29): | |
""" Build a deep recurrent network for speech | |
""" | |
# Main acoustic input | |
input_data = Input(name='the_input', shape=(None, input_dim)) | |
# TODO: Add recurrent layers, each with batch normalization | |
prev_layer = input_data | |
for layer in range(recur_layers): | |
prev_layer = GRU(units, activation='relu', | |
return_sequences=True, implementation=2, name=f'rnn_{layer+1}')(prev_layer) | |
# TODO: Add batch normalization | |
prev_layer = BatchNormalization()(prev_layer) | |
# TODO: Add a TimeDistributed(Dense(output_dim)) layer | |
time_dense = TimeDistributed(Dense(output_dim))(prev_layer) | |
# Add softmax activation layer | |
y_pred = Activation('softmax', name='softmax')(time_dense) | |
# Specify the model | |
model = Model(inputs=input_data, outputs=y_pred) | |
model.output_length = lambda x: x | |
print(model.summary()) | |
return model |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment