Hi,
I have looked at the other users’ posts who experienced the same error, but still couldn’t figure out how they resolved the issue. I am getting similar error. Any hint on identifying the bug is appreciated. My X and Y lists seem to be getting printed fine. X is having “None” at the head, Y having newline (0) at the tail and not having “None” at the head. Not sure what else is missing.
X = [None, 20, 21, 18, 9, 1, 19, 1, 21, 18, 21, 19]
Y = [20, 21, 18, 9, 1, 19, 1, 21, 18, 21, 19, 0]
IndexError Traceback (most recent call last)
in
----> 1 parameters, last_name = model(data.split(“\n”), ix_to_char, char_to_ix, 22001, verbose = True)
2
3 assert last_name == ‘Trodonosaurus\n’, “Wrong expected output”
4 print(“\033[92mAll tests passed!”)
in model(data_x, ix_to_char, char_to_ix, num_iterations, n_a, dino_names, vocab_size, verbose)
64 # Choose a learning rate of 0.01
65 print(" X = ", X, “\n”, "Y = ", Y, “\n”)
—> 66 curr_loss, gradients, a_prev = optimize(X, Y, parameters, a_prev, learning_rate=0.01)
67
68 ### END CODE HERE ###
in optimize(X, Y, a_prev, parameters, learning_rate)
32
33 # Forward propagate through time (≈1 line)
—> 34 loss, cache = rnn_forward(X, Y, a_prev, parameters)
35
36 # Backpropagate through time (≈1 line)
~/work/W1A2/utils.py in rnn_forward(X, Y, a0, parameters, vocab_size)
97
98 # Run one step forward of the RNN
—> 99 a[t], y_hat[t] = rnn_step_forward(parameters, a[t-1], x[t])
100
101 # Update the loss by substracting the cross-entropy term of this time-step from it.
~/work/W1A2/utils.py in rnn_step_forward(parameters, a_prev, x)
51 def rnn_step_forward(parameters, a_prev, x):
52
—> 53 Waa, Wax, Wya, by, b = parameters[‘Waa’], parameters[‘Wax’], parameters[‘Wya’], parameters[‘by’], parameters[‘b’]
54 a_next = np.tanh(np.dot(Wax, x) + np.dot(Waa, a_prev) + b) # hidden state
55 p_t = softmax(np.dot(Wya, a_next) + by) # unnormalized log probabilities for next chars # probabilities for next chars
IndexError: only integers, slices (:
), ellipsis (...
), numpy.newaxis (None
) and integer or boolean arrays are valid indices