Hello - i am struggling with the syntax to get x represented as a one-hot vector with the entry corresponding to predicted idx set = 1.
any suggestions for the right one-hot syntax welcome:
my code -which doesnt work - is below:
in sample(parameters, char_to_ix, seed)
63 # Step 4: Overwrite the input x with one that corresponds to the sampled index idx.
64 # (see additional hints above)
—> 65 x = np.eye(idx)
66 x[idx] = x[indices]
67
IndexError: arrays used as indices must be of integer (or boolean) type
Hello - note that my question is how to create a one-hot vector for x with the sampled idx.
for your suggestion x[idx] to be set equal to 1 - that throws a syntax error -
TypeError: ‘NoneType’ object does not support item assignment
ALL my struggles are about python syntax - sorry but even if I understand the concepts well, all my struggles are about the syntax, sorry but i dont know python well
thanks for any help, Ramesh
In Step 4, you did not complete the code for the x = … statement. Anywhere that you see “None” in the Notebook, you need to replace “None” with your code.
You need to set it to a vector of zeros, of size (vocab_list,1). Then you set the ‘idx’ element to 1.
That is how you create a one-hot vector.
Btw, I tried to delete the code in my post but could not I have flagged for Staff attention. Please feel free to remove any content code that does not fit rules.