Python Forum
Unable to understand reason for error IndexError: tuple index out of range
Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Unable to understand reason for error IndexError: tuple index out of range
#1
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
Reply
#2
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.
Reply
#3
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].
Reply
#4
s/b t[0], t[1], and  t[2]

t[3] is beyond the range of the tuple thus the error.
Reply
#5
(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
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Index out of range error standenman 0 1,037 May-22-2023, 10:35 PM
Last Post: standenman
  IndexError: invalid index to scalar variable. jyotib2610 3 2,991 Mar-10-2022, 09:55 AM
Last Post: jyotib2610
  IndexError: index 0 is out of bounds for axis 0 with size 0 atomxkai 2 5,362 Mar-03-2021, 08:26 AM
Last Post: atomxkai
  [split] Getting Index Error - list index out of range krishna 2 2,565 Jan-09-2021, 08:29 AM
Last Post: buran
  Cycle through Numpy range within another range(?) Zero01 0 1,993 Jul-31-2020, 02:37 PM
Last Post: Zero01
  Fatal Python error: initfsencoding: unable to load the file system codec gauravbhardwajee 12 28,033 Apr-30-2020, 07:45 PM
Last Post: barrpath
  IndexError: index 0 is out of bounds for axis 0 with size 0 tmhsa 0 5,270 Apr-24-2020, 10:00 AM
Last Post: tmhsa
  Getting Index Error - list index out of range RahulSingh 2 6,100 Feb-03-2020, 07:17 AM
Last Post: RahulSingh
  pandas.read_sas with chunksize: IndexError list index out of range axelle 0 2,549 Jan-28-2020, 09:30 AM
Last Post: axelle
  iterate over index and define each range as a day karlito 7 4,282 Nov-19-2019, 06:37 AM
Last Post: karlito

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020