Session Ready
Exercise

Create and initialize the input and target vectors

In this exercise, you'll encode the text input and target data to numeric values. You'll create two tensors x and y to contain these encodings. Input data is a set of sequences and so the tensor x will be three-dimensional. The first dimension is the number of samples, the second and third being the number of time-steps and the size of the vocabulary. Target data is a set of single characters and so y will be two dimensional. The first dimension will be the number of samples and the second will be the size of the vocabulary. You'll first define these tensors and then fill them up with data.

The vocabulary, length of each sequence, input data, target data, the character to integer mapping are saved in vocabulary, maxlen, input_data, target_data, char_to_idx respectively.

Instructions 1/2
undefined XP
  • 1
  • 2
  • Use np.zeros() to create a 3-D zero vector to contain the encoded input sequences.
  • Use np.zeros() to create a 2-D zero vector to contain the encoded target characters.