Codes returned by collate function in dataset.py have incorrect shape
Description of the bug While attempting to train the Hubert model with soft units on the GramVaani Hindi Dataset, I encountered a runtime error related to the loss function during training.
The error occurred during the execution of the line loss = F.cross_entropy(logits.transpose(1, 2), codes)) in train.py. The error message says RuntimeError: Expected target size [1, 256], got [1, 256, 256]. This suggests that the target tensor codes has an unexpected shape for the Cross Entropy Loss function. Upon inspection, it seems that the tensor codes returned from the collate() function in dataset.py has an incorrect shape.
I tried to fix this by slicing off the last dimension of target tensor codes to make it the expected size [1,256] but this doesn't work either.
Steps to reproduce
- Prepare the dataset by downsampling to 16k, converting to mono and wav, splitting into train and dev, and finally generating lengths.json with this script.
- Encode the dataset with
python encode.py --extension wav soft {in-dir} {out-dir} - Start training with
python train.py {dataset-dir} {checkpoint-dir} - Observe the runtime errors encountered during training.
Expected behaviour
The training process should run smoothly without encountering runtime errors related to the size of codes tensor.
Actual behaviour
The training begins but then fails with the described runtime error.
Impact This issue prevents the successful training of Hubert-Soft model on non-English datasets, affecting the ability to finetune Hubert-Soft, and consequently the SoftVC pipeline, for voice conversion tasks in Hindi and other Indian languages.
System Information Python: 3.10.13 Operating System: Ubuntu 22.04 LTS GPU: RTX5000 with 16GB VRAM
Any assistance in addressing this runtime error would be greatly appreciated @bshall.
I see what I was doing wrong. Instead of encoding the dataset into soft units, encode the dataset into discrete units. The soft encoder will then train to predict the discrete units.