My code is compiling, but getting wrong values output for sampling, the indices are wrong.
any clues? is my random choice statement correct?
idx = np.random.choice(list(range(vocab_size)),p=y.ravel())
Output
vocab_size = 27
np.shape(x) = (27, 1)
np.shape(Waa) = (100, 100)
np.shape(Wax) = (100, 27)
np.shape(Wya) = (27, 100)
np.shape(by) = (27, 1)
np.shape(b) = (100, 1)
np.shape(a_prev) = (100, 1)
np.shape(y) (27, 1)
np.sum(y.ravel()) 1.0
idx= 11
np.shape(y) (27, 1)
np.sum(y.ravel()) 0.9999999999999998
idx= 23
np.shape(y) (27, 1)
np.sum(y.ravel()) 0.9999999999999999
idx= 16
np.shape(y) (27, 1)
np.sum(y.ravel()) 0.9999999999999999
idx= 15
np.shape(y) (27, 1)
np.sum(y.ravel()) 1.0
idx= 1
np.shape(y) (27, 1)
np.sum(y.ravel()) 0.9999999999999998
idx= 23
np.shape(y) (27, 1)
np.sum(y.ravel()) 0.9999999999999997
idx= 23
np.shape(y) (27, 1)
np.sum(y.ravel()) 1.0000000000000002
idx= 13
np.shape(y) (27, 1)
np.sum(y.ravel()) 0.9999999999999999
idx= 17
np.shape(y) (27, 1)
np.sum(y.ravel()) 0.9999999999999999
idx= 17
np.shape(y) (27, 1)
np.sum(y.ravel()) 0.9999999999999997
idx= 0
Sampling:
list of sampled indices:
[11, 23, 16, 15, 1, 23, 23, 13, 17, 17, 0]
list of sampled characters:
[βkβ, βwβ, βpβ, βoβ, βaβ, βwβ, βwβ, βmβ, βqβ, βqβ, β\nβ]
AssertionError Traceback (most recent call last)
in
19 print("\033[92mAll tests passed!")
20
β> 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β
18
19 print("\033[92mAll tests passed!")
AssertionError: Wrong values