We will implement the pre-net block, which is being used in both the encoder and the decoder, as it is described in the paper. The simplicity and modularity of Keras make this part quite straightforward:
def get_pre_net(input_data):
prenet=Dense(256)(input_data)
prenet=Activation('relu')(prenet)
prenet=Dropout(0.5)(prenet)
prenet=Dense(128)(prenet)
prenet=Activation('relu')(prenet)
prenet=Dropout(0.5)(prenet)
return prenet