C5 W1 A2 UNQ_C4 giving error

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

Here is the code I tried.

{assignment code removed by mentor as we can’t share it here}

Hello @Raja_Tadimeti,

The error traceback can give us useful hint, so let’s analyze it from bottom up. The message said that this line had used indexing with invalid indices:

So, the program does not think that parameters is a dict! Let’s trace upwards and we can find this:

So, a_prev was passed as the parameters there!

Cheers,
Raymond

2 Likes

That really helped !! I can’t believe I made such a silly mistake. But looks like I am not out of woods yet. When I submitted my assignment for grading, I am getting below grader error output and getting 0/100. Note that I made sure “All tests are passed !” output is seen in all the test outputs.

Cell #10. Can’t compile the student’s code. Error: TypeError(‘cannot unpack non-iterable NoneType object’)

@Mubsi Lab ID is: uqpfdfsrokba

That “NoneType” error most likely means there is some code in the notebook that you haven’t completed yet. Search for “None” and have a look …

I searched for “None” and I do not see any other places other than explicitly adding it at the head of the list X as mentioned in the instructions.
If I want to take a fresh copy of blank assignment and code it again, what are the instructions ? When I click “?Help” and “get latest version”, It is not giving me blank document. Its giving me back the version which has previously submitted code.

That means you didn’t move the existing notebook out of the way first. Here’s a more complete (perhaps too complete) version of the instructions, which is also available from the DLS FAQ Thread.

If you read what it said when you did the “Get Latest Version” it explicitly pointed out that it will not replace existing files.

I followed the instructions, switched to a completely new notebook. This time I ensured that all my code was not at all present and then I recoded and submitted. Now I am getting below error :frowning: Even after 30 mins or so I am still getting the same error.

my lab ID is: uqpfdfsrokba

  • Platform Error: We’re experiencing some technical difficulties

Please try submitting again in 10 minutes. If the problem persists for 24 hours, please reach out to Coursera through our Help Center.

Even after couple of hours, I keep getting the same error. Could someone pls confirm if it is really a technical issue from coursera side OR some problem very specific to my submission ?

I just tried submitting the Dinosaur Island assignment (C5 W1 A2) and the Logistic Regression assignment (C1 W2 A2) and both gave me exactly the same error that you are seeing. So it looks like this is a general outage on the server side. The only thing I can suggest is to wait and try again every few hours. Sorry for the hassle, but it’s a Coursera issue.

1 Like

Thanks for the quick response.

Finally, now my submission is successfully graded and I got 100/100. Thanks a lot for all the help.