In the ‘sample’ function implementation, the input x:
x = np.zeros((vocab_size, 1))
then in the while loop:
while (idx != newline_character and counter != 50):
....
y = softmax(z)
x = np.zeros(y.shape)
...
In each iteration, y’s shape is always [27,1], so the “x = np.zeros(y.shape)” should be always of zeros of [27, 1], which is the same as the x’s initialization outside of the while loop. So I thought I don’t really need the “x = np.zeros(y.shape)” line inside the loop, because it will result in the same x as the ‘x’ outside of the loop. However, if I comment out this assignment line, it reports an error.
What’s wrong with my understanding?