Week 1 - Assignment 2 Dino model() function

Hello everyone, today I’m trying to do the exercice and I don’t know where is my mistake, I did this code:

{mentor edit: code removed - not allowed by the Honor Code}

and I have this error:

~/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)

TypeError: ‘int’ object is not subscriptable

Someone can help me?
Thanks

Please edit your message and remove your code. Posting your code breaks the course Honor Code.

(edit: bad advice removed)

Hello TMosh, for me not appear the option to edit the post, I don’t know why, I’m checking your points, thanks

I’ll remove the code from your message.

Also, some of my advice was wrong, since those related to code that is provided for you. I’ve edited my replies.

1 Like

Also, I’ve edited the thread title to put it in the correct exercise (C5 Week 1 Assignment 2, function “model()”.

1 Like

I think I found the problem. Your reference to X[1] should be X[1:].

  • X[1] only gives you one letter.
  • X[1:] gives you all the letters after the skipping the first element.
1 Like