Week1 : def sample Dinosaurus Island

I am not able to figure out the shape of x and a_prev for np.zeros() function . Could anybody please help me out

The additional implementation notes said:

  • x⟨1⟩ is x in the code. When creating the one-hot vector, make a numpy array of zeros, with the number of rows equal to the number of unique characters, and the number of columns equal to one. It’s a 2D and not a 1D array.
  • a⟨0⟩ is a_prev in the code. It is a numpy array of zeros, where the number of rows is 𝑛𝑎na, and number of columns is 1. It is a 2D array as well. na is retrieved by getting the number of columns in 𝑊𝑎𝑎Waa (the numbers need to match in order for the matrix multiplication Waaa⟨t⟩ to work.

for x, the size should be (vocab_size,1)
a_prev, the size should be (n_a,1)


In addition, where x is derived from vocab_size = by.shape[0], what is the relation between by and the number of unique characters?

Hi @Dana ,

‘by’ is a vector contains randomly generated values for the y’s bias. Each value is for each characher in the vocabulary, and it has a shape of (vocab_size, 1). Therefore, to extract the size of the vocabulary:
vocab_size = by.shape[0]

1 Like