This is my 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]))
in predict_and_sample(inference_model, x_initializer, a_initializer, c_initializer)
21 indices = np.argmax(pred, axis=-1)
22 # Step 3: Convert indices to one-hot vectors, the shape of the results should be (1, )
—> 23 results = to_categorical(indices, num_classes=78)
24 ### END CODE HERE ###
25
/opt/conda/lib/python3.7/site-packages/tensorflow/python/keras/utils/np_utils.py in to_categorical(y, num_classes, dtype)
76 n = y.shape[0]
77 categorical = np.zeros((n, num_classes), dtype=dtype)
—> 78 categorical[np.arange(n), y] = 1
79 output_shape = input_shape + (num_classes,)
80 categorical = np.reshape(categorical, output_shape)
IndexError: index 82 is out of bounds for axis 1 with size 78
I suspect it to be either in step 2 or 3, but can exactly diagnose the issue, and I’m confused why it’s arbitrarily bringing up the number 82. I also believe my music_inference_model should be correct.
Thanks for the help in advance!
Edit1:
I just read one of the discourse messages from one of the mentors.
(step 3 of predict and sample)
results = … num_classes=n_values)
I originally had it set to
results = … num_classes=78)
I just wanted to ask why in the instructions, it specifies not to use num_classes=n_values when the grader only deems it correct once you have it as results = … num_classes=n_values)?
Edit2: Source Code Removed