Course 3, W1 Ex. 8

I get the following error: “IndexError: list index out of range” even when just iterating over the generator provided to the function in the test cell (before the unit test). So even when the body is empty, the following invokes this error:
IndexError: list index out of range

for batch in generator:

The code from the test cell is:

model = training_loop.eval_model

accuracy = test_model(test_generator(16, val_pos
, val_neg, Vocab, loop=False
, shuffle = False), model)

So just iterating over the test_generator created here leads to range error.
Any ideas?

Hi,
I guess you should check your ‘accuracy’ again, specifically in test_generator function.

Thanks! well, the problem turned out to be in the data_generator - an issue that didn’t occur with any of the other tests, so all of them passed but the lst

I used i instead of neg_index:

If the negative index goes past the negative dataset,

if i >= len_data_neg:

instead of
if neg_index >= len_data_neg:

:slight_smile: