mhamilton723 / STEGO

Unsupervised Semantic Segmentation by Distilling Feature Correspondences
MIT License
712 stars 143 forks source link

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

Open Sehjbir opened 2 years ago

Sehjbir commented 2 years ago

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 commented 2 years ago

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

WParameterization commented 2 years ago

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

yanxiangyi commented 2 years ago

Same here.

b1a0 commented 2 years ago

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.

KennyChen880127 commented 1 year ago

@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!

b1a0 commented 1 year ago

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

KennyChen880127 commented 1 year ago

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.

www545 commented 2 months ago

@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

KennyChen880127 commented 2 months ago

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

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