Skip to Content
Deep Learning Quick Reference
book

Deep Learning Quick Reference

by Mike Bernico
March 2018
Intermediate to advanced
272 pages
7h 53m
English
Packt Publishing
Content preview from Deep Learning Quick Reference

Decoding a sequence

The decoder needs the following two things to start its work:

  • State from the encoder.
  • An input signal that starts the predicted translation. We will send it a '\t' in a one hot vector as that's our <SOS> character.

To obtain the encoder state, we just need to send the vectorized version of the phrase we want to translate to the encoder, using the following code:

states_value = encoder_model.predict(input_seq)

In order to start the decoder, we also need a one hot vector containing the <SOS> character. This code gets us there:

target_seq = np.zeros((1, 1, data['num_decoder_tokens']))target_seq[0, 0, data['target_token_index']['\t']] = 1.

And now we're ready to set up a decoder loop that will generate our translated phrase, ...

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

Keras Deep Learning Cookbook

Keras Deep Learning Cookbook

Rajdeep Dua, Sujit Pal, Manpreet Singh Ghotra
Deep Learning with Keras

Deep Learning with Keras

Antonio Gulli, Sujit Pal

Publisher Resources

ISBN: 9781788837996Supplemental Content