Dinosaurus_Island_Character_level_language_model under Function Sample

Hello Please under the Sample function , I get the follwing error:

list of sampled indices:
[23, 15, 23, 22, 25, 5, 15, 23, 23, 25, 25, 14, 1, 2, 12, 16, 17, 0]
list of sampled characters:
[‘w’, ‘o’, ‘w’, ‘v’, ‘y’, ‘e’, ‘o’, ‘w’, ‘w’, ‘y’, ‘y’, ‘n’, ‘a’, ‘b’, ‘l’, ‘p’, ‘q’, ‘\n’]

AssertionError Traceback (most recent call last)
19 print("\033[92mAll tests passed!")
—> 21 sample_test(sample)

in sample_test(target)
15 assert indices[-1] == char_to_ix[’\n’], “All samples must end with \n”
16 assert min(indices) >= 0 and max(indices) < len(char_to_ix), f"Sampled indexes must be between 0 and len(char_to_ix)={len(char_to_ix)}"
—> 17 assert np.allclose(indices[0:6], [23, 16, 26, 26, 24, 3]), “Wrong values”
19 print("\033[92mAll tests passed!")

AssertionError: Wrong values

Please any help

1 Like

Hi @Marvin ,

The assertion is trigger because the first 6 elements in indices do not match the [23, 16, 26, 26, 24, 3] elementwise. So you need to check the sample function() carefully. Print statement is very helpful for debugging.

Still struggling to idnetify the error

I figured it out thanks @Kic

great to hear. Thanks

I have very similar problem and stuck since weeks. Could you give me a hint how did you figure it out? Thank you very much!

Make sure you are overwriting the input x with 1 that corresponds to tha sampled index ‘idx’

Thank you for your replay. I did check the input of x. It was okay. But I still get wrong result.

This saved tons of my time. Thanks!