Skip to content

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

@Xiaowei-coder

Description

@Xiaowei-coder

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions