Hi,
I found something wrong in the assignment ‘Dinosaurus_Island_Character_level_language_model’ I doubt.
Example of how to use np.random.choice() :
np.random.seed(0)
probs = np.array([0.1, 0.0, 0.7, 0.2])
idx = np.random.choice(range(len(probs), p = probs))
I think it should be … idx = np.random.choice(range(len(probs)), p = probs)
Its the other way round for me. The suggestion by @jason1 worked fine and the hint in the assignment did not. It threw the error “range() takes no keyword arguments”. Could you explain what’s going on ?
From the instruction, the code idx = np.random.choice(range(len(probs), p = probs)) throws error
where as what @jason1 suggested idx = np.random.choice(range(len(probs)), p = probs) runs without error. (I mean just this line of code, not the assignment block)
So I couldn’t understand from what you meant by Your suggestion should produce a compilation error since there’s an extra closing bracket after p=probs