STEGO icon indicating copy to clipboard operation
STEGO copied to clipboard

Training error on custom dataset(no labels): IndexError: index 4 is out of bounds for dimension 0 with size 4 in validation_epoch_end

Open Sehjbir opened this issue 2 years ago • 9 comments

I'm getting this error:

File "train_segmentation.py", line 292, in validation_epoch_end ax[0, i].imshow(prep_for_plot(output["img"][i])) IndexError: index 4 is out of bounds for dimension 0 with size 4

I'm using custom dataset with no labels, cropping and pre-computing knns worked fine.

Sehjbir avatar May 09 '22 20:05 Sehjbir

I was able to resolve the issue. The batch size was set to 4 and I was using n_images =5 in cfg file during logging. Training epoch completed. However durring validation step I'm getting this error:

image

Sehjbir avatar May 09 '22 21:05 Sehjbir

Hi, Sehjbir: Have you solved this problem? I also encountered the same error.

WParameterization avatar May 26 '22 09:05 WParameterization

Same here.

yanxiangyi avatar May 28 '22 07:05 yanxiangyi

I had the same issue. I believe the problem occurs when the batch size does not exactly divide the number of images available and when one batch is not a "full one" but the random number for showing the images is sampled outside of the actual number of images available. At least when I made the number of images divisible by the batch size, the problem disappeared.

b1a0 avatar Jul 04 '22 10:07 b1a0

@b1a0 thank you I'm try your way and solved this issuie! But I'm stuck in Epoch1: 69% and then stop...Do you encounter this issuie? thanks a lot!

KennyChen880127 avatar Dec 15 '22 05:12 KennyChen880127

To the best of my knowledge, I didn't have this issue when I tried this a few month ago.

b1a0 avatar Dec 15 '22 09:12 b1a0

Hello everyone! I had been changing the batch size to equal the n_image.It's can use on Linux. But now I can't fix this glitch on Windwos10! IndexError: invalid index of a 0-dim tensor. Use tensor.item() in Python or tensor.item<T>() in C++ to convert a 0-dim tensor to a number Hope somebody can help me! thanks a lot.

KennyChen880127 avatar Feb 12 '23 10:02 KennyChen880127

@KennyChen880127 Have you solve this problem? I also have this issue。 IndexError: invalid index of a 0-dim tensor. Use tensor.item() in Python or tensor.item<T>() in C++ to convert a 0-dim tensor to a number

www545 avatar Jun 26 '24 06:06 www545

@KennyChen880127你解決這個問題了嗎?我也有這個問題 。tensor.item()在 Python 或C++ 中使用tensor.item<T>()將 0 維張量轉換為數字

Hi there! I ultimately resolved the issue by switching to Ubuntu 20.04.

KennyChen880127 avatar Jun 26 '24 09:06 KennyChen880127