Session Ready
Exercise

Create input and target tensors

In this exercise, you'll create two tensors to encode the input and the target sequences. The input is a list containing all the names in the dataset. So, the first dimension of the input tensor will be the number of names in the dataset. Each name can be thought of as a string having length equal to the length of the longest name and each character in each name is a one-hot encoded vector of size vocabulary. So, the second and third dimensions of the input tensor will be the length of the longest name and the size of the vocabulary. Similar is the case for the target tensor.

The dataset and the vocabulary are available in names_df and vocabulary. A function named get_max_len() is available which takes a list of names as input and returns the length of the longest name.

Instructions
100 XP
  • Use the predefined function get_max_len() to find the length of the longest name.
  • Use np.zeros() to define two zero tensors of appropriate shape for the input and the target data.