sherjilozair / char-rnn-tensorflow

Multi-layer Recurrent Neural Networks (LSTM, RNN) for character-level language models in Python using Tensorflow
MIT License
2.64k stars 960 forks source link

weighted_pick() gives random choices? #32

Closed totuta closed 8 years ago

totuta commented 8 years ago

Hi, does weighted_pick() return random characters?

with sampling_type=1, return(int(np.searchsorted(t, np.random.rand(1)*s))) looks like giving a random choice out of the array t. And that's what I'm having right now. Is it intentional? Or am I doing something wrong?

totuta commented 8 years ago

Now I got it. t = np.cumsum(weights) makes characters with higher probability to have bigger interval just before itself and that makes the seemingly random choice to be weighted pick. Makes sense.