Skip to content
This repository has been archived by the owner on Sep 28, 2021. It is now read-only.

Validation set error during training--> IndexError: index 32 is out of bounds for axis 2 with size 32 #11

Open
inkplatform opened this issue Jun 22, 2021 · 1 comment

Comments

@inkplatform
Copy link

Hello Sir
I used your code to validate the dataset size as data_loader=373 and got an error while validating as follows.
When
for i, (data, target, coord) in enumerate(data_loader):

The following error message appears when the loop reaches the 66th time.

IndexError: index 32 is out of bounds for axis 2 with size 32

Can you help me please? Thank you.

@inkplatform
Copy link
Author

inkplatform commented Jun 23, 2021

I debugged the code and found that the place variable was calculated to exceed the bounds of the target, as shown in the following code:

for ax in range(len(patch.shape)):
window = int(BLOCK_SIZE / TARGET_SHAPE[ax])
windows.append(window)
place.append(centers[c][ax] // window)
point.append(centers[c][ax] % window)

So I modified the code to validate the centroid and put a limit on the values that exceed the target boundary. The following code is shown:

for ax in range(len(patch.shape)):
window = int(BLOCK_SIZE / TARGET_SHAPE[ax])
windows.append(window)
val_centers = centers[c][ax] // window
if val_centers >= COORDS_CUBE_SIZE:
val_centers = COORDS_CUBE_SIZE-1
place.append(val_centers)
point.append(centers[c][ax] % window)

Is the modification here reasonable and is there a better solution?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant