Skip to Content
Deep Learning with Keras
book

Deep Learning with Keras

by Antonio Gulli, Sujit Pal
April 2017
Intermediate to advanced
318 pages
7h 40m
English
Packt Publishing
Content preview from Deep Learning with Keras

Look up embeddings

Our final strategy is to look up embeddings from pre-trained networks. The simplest way to do this with the current examples is to just set the trainable parameter of the embedding layer to False. This ensures that backpropagation will not update the weights on the embedding layer:

model.add(Embedding(vocab_sz, EMBED_SIZE, input_length=maxlen,                     weights=[embedding_weights],                     trainable=False))model.add(SpatialDropout1D(Dropout(0.2)))

Setting this value with the word2vec and GloVe examples gave us accuracies of 98.7% and 98.9% respectively after 10 epochs of training.

However, in general, this is not how you would use pre-trained embeddings in your code. Typically, it involves preprocessing your dataset to create word vectors ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Advanced Deep Learning with Keras

Advanced Deep Learning with Keras

Rowel Atienza, Neeraj Verma, Valerio Maggio
Deep Learning with TensorFlow 2 and Keras - Second Edition

Deep Learning with TensorFlow 2 and Keras - Second Edition

Antonio Gulli, Dr. Amita Kapoor, Sujit Pal

Publisher Resources

ISBN: 9781787128422Supplemental Content