-
Notifications
You must be signed in to change notification settings - Fork 311
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Index out of range error #279
Comments
@RaviTej310 You cannot use a LookupTable with images. You should instead use a Linear or SpatialConvolution. PR #280 is a very rough draft of how to use SpatialConvolution with Recurrence. It does not run, but the part about building the model should give you an idea. |
Sorry but I get the same error with LSTM on stock indices (not images) :
Almost the same stack :( The problem occurs when feeding the LookupTable on mini-batch. Could someone points us to a relevant example (with at least dim-2d input Tensor not torch.randperm() please.......!!!) ? Many thanks |
@scalastic Usually, index out of range error occurs when you have an invalid index. For example, with a lookup table of 100 indices, only indexes between 1 and 100 will be valid. Here is a 2d example: -- 3 x 4 tensor of indices randomly sampled between 1 and 100
input = torch.LongTensor(3,4):random(1,100)
-- lookup table consisting of 100 embeddings of 5 units each:
lookup = nn.LookupTable(100, 5)
-- forward indices through
lookup:forward(input)
(1,.,.) =
-0.3788 0.7058 0.4782 -1.0016 0.3914
0.6950 -1.1974 1.4737 0.0400 0.3055
-0.4760 -0.7315 0.3597 -0.8322 -0.8582
0.1845 -0.9815 -0.6764 -0.4099 2.3405
(2,.,.) =
-0.4075 -0.3032 0.4292 0.6594 1.1332
-0.3993 1.6485 -0.2334 -0.4767 -1.1654
0.2760 0.8907 0.4681 0.2643 0.7932
-0.6268 0.6494 -1.2751 2.0526 -0.3467
(3,.,.) =
-0.2379 -0.5717 -0.7413 0.9472 0.6435
-1.1906 -1.0219 1.1680 -0.3493 -0.0208
0.1248 0.5194 -1.0458 1.8812 0.0879
-1.4082 -0.2250 -0.4062 -0.8765 -0.2728
[torch.DoubleTensor of size 3x4x5] Here is an example of a similar error (line 75 instead of 73 because 2d instead of 1d): -- out of range (102 > 100)
input[1][1] = 102
lookup:forward(input)
/usr/local/share/lua/5.1/nn/LookupTable.lua:75: index out of range at /tmp/luarocks_torch-scm-1-9702/torch7/lib/TH/generic/THTensorMath.c:156
stack traceback:
[C]: in function 'index'
/usr/local/share/lua/5.1/nn/LookupTable.lua:75: in function 'forward'
[string "_RESULT={lookup:forward(input)}"]:1: in main chunk
[C]: in function 'xpcall'
/usr/local/share/lua/5.1/trepl/init.lua:651: in function 'repl'
/usr/local/lib/luarocks/rocks/trepl/scm-1/bin/th:199: in main chunk
[C]: at 0x00405e60 |
@nicholas-leonard Thank you for your answer. I'm on the move right now, I'll watch all this in few days and I'll give you my feedback. |
I am trying to implement a different version of this simple recurrent network which accepts three image of 200x200 and predicts a fourth. I modified it as:
But I'm getting an index out of range error:
What is going wrong and how can I fix this?
The text was updated successfully, but these errors were encountered: