xiph / xiph/opus

RuntimeError: Index -1 is out of bounds for dimension 1 with size 256 during inference with FarGAN

Open
#427 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
3.3k
Forks
808
PR merge metrics
No merged PRs in 30d

Description

Description

Hello, I encountered an issue while testing the retrained FarGAN model after adding a new dataset to tts_speech_negative_16k.sw. Below are the steps I followed:

  1. Data Dumping:
    ./dump_data -train ../../opus/dnn/torch/fargan/tts_speech_negative_16k.sw ../dump_feature/out_features.f32 ../dump_feature/out_speech.pcm

  2. Training:
    python ./train_fargan.py ../dump_feature/out_features.f32 ../dump_feature/out_speech.pcm output_dir --epochs 400 --batch-size 2048 --lr 0.002 --cuda-visible-devices 0

  3. Adversarial Training:
    python adv_train_fargan.py ../dump_feature/out_features.f32 ../dump_feature/out_speech.pcm output_dir --lr 0.000002 --reg-weight 5 --batch-size 160 --cuda-visible-devices 0 --initial-checkpoint output_dir/checkpoints/fargan_400.pth

  4. Testing:
    python test_fargan.py output_dir/checkpoints/fargan_adv_1.pth ../dump_feature/test_features.f32 output_speech.pcm

During Step 4 (testing), the following error occurred:

File "/home/fxw/SE/deep_enc_dec/fargan_enc_dec/train_fargan/fargan.py", line 255, in forward
    pred = torch.gather(exc_mem, 1, idx)
RuntimeError: index -1 is out of bounds for dimension 1 with size 256
Image Image

The issue arises because idx contains negative values (-1), which is invalid for indexing dimension 1 of a tensor with size 256.

Possible Causes and Questions
  1. Data Preprocessing: Could the new dataset introduced values that lead to invalid indices during inference?
  2. Model Compatibility: Does the model architecture or training process require adjustments when adding new data?
  3. Index Calculation: Is there a potential issue in the code logic that computes idx (e.g., miscalculations or out-of-range values)?
Request for Help

I would appreciate any insights into why idx might contain negative values and I want to fix it, but I don't know why this is happening. Thank you!

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with fargan.py around line 255 and reproduce Step 4 using test_fargan.py and the checkpoint and feature files from the report. Trace where idx is calculated and compare it with the inference inputs and training data; done means identifying why -1 appears and confirming inference no longer fails with invalid indices.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, pytorch
Domain
audio-video-rtc, machine-learning
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.