IndexError: understanding too many indications for array

Asked 2 years ago, Updated 2 years ago, 44 views

I understand that there are many similar questions, but the code that should have worked is
As it no longer works, I am posting without knowing the cause.

The following error occurred in the SSD learning program:

File "train.py", line 201, generate
    img,y=self.horizontal_flip(img,y)
  File "train.py", line 117, inhorizontal_flip
    y[:,[0,2]] = 1-y[:,[2,0]]
IndexError: too many indications for array

The program descriptions are as follows:

200 if self.hflip_prob>0:
201 img,y=self.horizontal_flip(img,y)    
114 default horizontal_flip(self,img,y):
115 if np.random.random()<self.hflip_prob:
116 img = img [:,:-1]
117y[:,[0,2]] = 1-y[:,[2,0]]                                                                       
118 return img,y

This program was working a little while ago, but
·Updated learning data
·Rewrite train.py with some kind of mistake
·Python version (although there is no change in recognition)
I am having trouble identifying the cause.
We may not have enough information, but we appreciate your cooperation.

python numpy

2022-09-29 22:17

1 Answers

y[:,[0,2]]=1-y[:,[2,0]] has an error, but the error code IndexError: too many indexes for array means that the index dimension of the slice is larger than the array dimension, so the variable y must actually be one or more dimensions.

The problem appears to have occurred before the code provided in the question, and it says, "Maybe it's not enough information."


2022-09-29 22:17

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.