Dinosaur Island-Character-Level Language Modeling- error in final exercise

I have been trying to get the final output but it is showing me the wrong expected output!
I wrote the following code-

### START CODE HERE ###


** # Set the index idx (see instructions above)**
** idx = j%len(examples)**


** # Set the input X (see instructions above)**
** single_example = examples[idx]**
** single_example_chars = [c for c in single_example]**
** single_example_ix = [char_to_ix[ch] for ch in single_example_chars]**
** X = [char_to_ix[ch] for ch in examples[idx]]**


** # Set the labels Y (see instructions above)**
** ix_newline = char_to_ix["\n"]**
** Y = X[1 :] + [ix_newline]**

** # Perform one optimization step: Forward-prop → Backward-prop → Clip → Update parameters**
** # Choose a learning rate of 0.01**
** curr_loss, gradients, a_prev = optimize(X, Y, a_prev, parameters, learning_rate =0.01)**


** ### END CODE HERE ###**

Hello UTKARSH2310, it seems that you have not prepended [None] to your X.

do you mean should try with something like this–
X = [None] + [char_to_ix[ch] for ch in examples[idx]]

?

I think you shouldn’t copy others’ code from github, it is illegal against coursera Honor Code!

1 Like