Hello, I’m on Exercise 2, sample() function, of the Dinosaur assignment (Assignment 2).
Regarding step 4 inside the while loop:
# Step 4: Overwrite the input x with one that corresponds to the sampled index `idx`.
# (see additional hints above)
x = None
x[idx] = 1
Per the instruction, I should turn x into the one-hot vector for every iteration through the while loop. Because x was initialized to a zero vector prior to the while loop, x = np.zeros(vocab_size). Should I just need to set x[idx] = 1 ? Why do I have to overwrite the input x with one that corresponds to the sampled index idx
before setting x[idx] = 1 ? That’s where I got confused ! Thanks.