Predict_and_sample() issue with grader

I eventually submitted my assignment since I was closely approaching the deadline (1 hour left). I kept getting this error when running the following cell:

results, indices = predict_and_sample(inference_model, x_initializer, a_initializer, c_initializer)

print(“np.argmax(results[12]) =”, np.argmax(results[12]))
print(“np.argmax(results[17]) =”, np.argmax(results[17]))
print(“list(indices[12:18]) =”, list(indices[12:18]))

ERROR:

IndexError Traceback (most recent call last)
in
1 results, indices = predict_and_sample(inference_model, x_initializer, a_initializer, c_initializer)
2
----> 3 print(“np.argmax(results[12]) =”, np.argmax(results[12]))
4 print(“np.argmax(results[17]) =”, np.argmax(results[17]))
5 print(“list(indices[12:18]) =”, list(indices[12:18]))

IndexError: index 12 is out of bounds for axis 0 with size 1

I went ahead and read the Discourse discussions of other people encountering this issue. None of the advice provided helped. Eventually I submitted the assignment. To my surprise I still received 100/100. I’m just wondering what is wrong here? Either part of that cell is buggy or there is something amiss with the grader.

More than anything want to make sure that future students that take this part of the course don’t face this issue if it is in fact a bug in the assignment.

When you got this error when running the notebook, did you try restaring the kernel and running all of the cells again?

Yes. Did that about 3 times. Same error.

Did you hit “Save” before you submitted to the grader? I don’t think the graders in Courses 4 and 5 do an automatic Save for you. So what the grader saw may not be the same as what you are seeing. Meaning that the code used to be correct, but you subsequently broke it. You should be able to debug why the dimensions of “results” are incorrect. What is the shape you are getting? Why did it turn out incorrectly? FWIW I did not see this error and also get 100/100 from the grader, so it must be something particular to your case.

Of course it is also possible that the grader does not catch all errors. Please investigate why your results value is the wrong shape and let us know what you find.