trying to debug exercise 4.
I suspect there is something wrong with theY
.
I have set Y
to equal to elements fromX
starting from the first element, so this should take care of the link between y and x highlighted in yellow. but the very last element (green) is not added to Y
.
I thought at first that it would be resolved by appending Y with last_dino_name
as a list addition, but this does not work either. Not sure what last_dino_name
does in the code
Do I need to forward propagate the last element of x to get the y and add it to the current Y value? Or is it the character to represent end of the word?
The code expects a 1 line solution, so not sure if this is what is expected in this exercise.
j 0 range range(0, 22001)
single_example: aachenosaurus
single_example_chars: ['a', 'a', 'c', 'h', 'e', 'n', 'o', 's', 'a', 'u', 'r', 'u', 's']
single_example_ix: [1, 1, 3, 8, 5, 14, 15, 19, 1, 21, 18, 21, 19]
X: [None, 1, 1, 3, 8, 5, 14, 15, 19, 1, 21, 18, 21, 19]
Y: [1, 1, 3, 8, 5, 14, 15, 19, 1, 21, 18, 21, 19]
---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
<ipython-input-102-725c093d6b91> in <module>
----> 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!")
<ipython-input-101-10a8c686571a> in model(data_x, ix_to_char, char_to_ix, num_iterations, n_a, dino_names, vocab_size, verbose)
64 # Perform one optimization step: Forward-prop -> Backward-prop -> Clip -> Update parameters
65 # Choose a learning rate of 0.01
---> 66 curr_loss, gradients, a_prev = optimize(X, Y, a_prev, parameters, learning_rate = 0.01)
67
68 ### END CODE HERE ###
<ipython-input-93-fca0aba78113> 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)
100
101 # Update the loss by substracting the cross-entropy term of this time-step from it.
--> 102 loss -= np.log(y_hat[t][Y[t],0])
103
104 cache = (y_hat, a, x)
IndexError: list index out of range