SHARE
TWEET

Untitled

a guest Aug 19th, 2019 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def generator():
  2.     i = 0
  3.     encoder_input_data = np.zeros(
  4.         (batch_size, max_encoder_seq_length, num_encoder_tokens),
  5.         dtype='float32')
  6.     decoder_input_data = np.zeros(
  7.         (batch_size, max_decoder_seq_length, num_decoder_tokens),
  8.         dtype='float32')
  9.     decoder_target_data = np.zeros(
  10.         (batch_size, max_decoder_seq_length, num_decoder_tokens),
  11.         dtype='float32')
  12.     for i, (input_text, target_text) in enumerate(zip(input_texts, target_texts)):
  13.         i = i + 1
  14.         if i == batch_size:
  15.             yield [encoder_input_data, decoder_input_data], decoder_outputs
  16.             i = 0
  17.             encoder_input_data = np.zeros(
  18.                 (batch_size, max_encoder_seq_length, num_encoder_tokens),
  19.                 dtype='float32')
  20.             decoder_input_data = np.zeros(
  21.                 (batch_size, max_decoder_seq_length, num_decoder_tokens),
  22.                 dtype='float32')
  23.             decoder_target_data = np.zeros(
  24.                 (batch_size, max_decoder_seq_length, num_decoder_tokens),
  25.                 dtype='float32')
  26.  
  27.         for t, char in enumerate(input_text):
  28.             encoder_input_data[i % batch_size, t, token_index[char]] = 1.
  29.         for t, char in enumerate(target_text):
  30.             decoder_input_data[i % batch_size, t, token_index[char]] = 1.
  31.             if t > 0:
  32.                 decoder_target_data[i % batch_size, t - 1, token_index[char]] = 1.
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top