O'Reilly logo

Hands-On Natural Language Processing with Python by Rajalingappaa Shanmugamani, Rajesh Arumugam

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Pre-net 

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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required