W1 A2: model Function: indexing error

Not able to get past the error:

only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boolean arrays are valid indices

My X, Y and a_prev print outputs right before calling the optimize function:

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]
(50, 1)

Really cant figure out what could be wronng here.

Please post a screen capture image that shows the error message and your other test results.

Here’s some of the output I get when I run the model function in that test cell:

initial loss 23.070858062030304
j =  0 idx =  0
single_example = turiasaurus
single_example_chars ['t', 'u', 'r', 'i', 'a', 's', 'a', 'u', 'r', 'u', 's']
single_example_ix [20, 21, 18, 9, 1, 19, 1, 21, 18, 21, 19]
 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]

Notice that the first element in my X list is the python token None. In your list it is the string 'None'. That’s not the same thing, right? Maybe that could cause the issue you’re seeing.

Hey, thanks so much for helping with this. It was such a silly mistake!!

Thanks.

1 Like