March 2018
Intermediate to advanced
272 pages
7h 53m
English
The decoder needs the following two things to start its work:
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, ...