Python Forum

Full Version: Unable to understand reason for error IndexError: tuple index out of range
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello this is my first post.I am getting the following error..


Quote:WARNING:tensorflow:From create_animation.py:207 in main.: initialize_all_variables (from tensorflow.python.ops.variables) is deprecated and will be removed after 2017-03-02.
Instructions for updating:
Use tf.global_variables_initializer instead.
 No checkpoint found
(0,)
(0,)
0
(0,)
amount of triplets is -2
Traceback (most recent call last):
  File "create_animation.py", line 282, in <module>
    main()
  File "create_animation.py", line 226, in main
    for batchx, batchy in create_batch(scene):
  File "create_animation.py", line 165, in create_batch
    data, y = create_triplets(scene)
  File "create_animation.py", line 153, in create_triplets
    input_duos = np.zeros((int(triplet_len/2)+1, images_shape[1], images_shape[2], images_shape[3] * 2))
IndexError: tuple index out of range

The code is a bit long and I am unable to provide links here(until I prove I am not a spammer!). Please let me know if you like to see the code and how I can share it with you.

This is an implementation of a research paper. I have copied this code from github and want to execute it so that I can gain deeper understanding of the concepts mentioned in the paper.
I really need your help.
Thanks in advance
Are you able to reproduce the problem with fewer lines? You should be able to hard-code whatever variables the problem line depends on with 5-10 lines, and still reproduce the problem you're seeing.
In line 153 this happens.
>>> t = (1, 2, 3)
>>> t[2]
3
>>> t[3]
Error:
Traceback (most recent call last):  File "<string>", line 301, in runcode  File "<interactive input>", line 1, in <module> IndexError: tuple index out of range
So you are trying to access a tuple value that has no index. 
So you have to check data(index) before it been used in this line.
Simple print() can help to understand eg print([color=#333333][size=small]images_shape[2])[/size][/color].
s/b t[0], t[1], and  t[2]

t[3] is beyond the range of the tuple thus the error.
(Dec-08-2016, 06:55 PM)rajat2504 Wrote: [ -> ]I have copied this code from github and want to execute it so that I can gain deeper understanding of the concepts mentioned in the paper.

If you did not code this yourself, you can file a bug report on github, so the author can review