hubert icon indicating copy to clipboard operation
hubert copied to clipboard

Codes returned by collate function in dataset.py have incorrect shape

Open arjbah opened this issue 2 years ago • 1 comments

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

  1. 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.
  2. Encode the dataset with python encode.py --extension wav soft {in-dir} {out-dir}
  3. Start training with python train.py {dataset-dir} {checkpoint-dir}
  4. 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. Screenshot from 2024-03-11 12-00-40 Screenshot from 2024-03-11 12-00-16

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.

arjbah avatar Mar 11 '24 07:03 arjbah

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.

arjbah avatar Mar 14 '24 04:03 arjbah