karpathy / char-rnn

Multi-layer Recurrent Neural Networks (LSTM, GRU, RNN) for character-level language models in Torch
11.63k stars 2.59k forks source link

Multinomial Error #152

Open qingyuanxingsi opened 8 years ago

qingyuanxingsi commented 8 years ago

When I run the code using my customized data, I found the following error, which had been mentioned by previous issues(but not solved),

/home/abc/torch/install/bin/luajit: bad argument #2 to '?' (out of bounds at /home/abc/torch/pkg/torch/lib/TH/generic/THStorage.c:178)
stack traceback:
    [C]: at 0x7f3c95023650
    [C]: in function 'multinomial'
    sample.lua:149: in main chunk
    [C]: in function 'dofile'
    .../abc/torch/install/lib/luarocks/rocks/trepl/scm-1/bin/th:145: in main chunk
    [C]: at 0x00406620

Would you be so kind as to tell me how to solve this issue??

allthetime commented 8 years ago

I also experience this when attempting to sample from check points...

afoland commented 8 years ago

This seems likely related to https://www.bountysource.com/issues/28133409-434-breaks-multinomial ; I did find in my sampling that the code fails on a prediction where one output has probability 1.0000 (printed to 4 digits). I verified that the probs are all positive semi-definite and none are NaN.

According to the discussion, the solution is to make cum_dist in THTensorRandom.c a DoubleTensor but I haven't tried it myself.