pytorch-StarGAN-VC icon indicating copy to clipboard operation
pytorch-StarGAN-VC copied to clipboard

RuntimeError: Assertion `cur_target >= 0 && cur_target < n_classes' failed

Open yourlin opened this issue 5 years ago • 2 comments

The number of parameters: 33428 Start training...... /usr/local/lib/python3.7/site-packages/torch/nn/modules/container.py:92: UserWarning: Implicit dimension choice for log_softmax has been deprecated. Change the call to include dim=X as an argument. input = module(input) Traceback (most recent call last): File "main.py", line 91, in main(config) File "main.py", line 35, in main solver.train() File "/Users/linye/PycharmProjects/pytorch-StarGAN-VC/solver.py", line 160, in train cls_loss_real = CELoss(input=cls_real, target=speaker_idx_org) File "/usr/local/lib/python3.7/site-packages/torch/nn/modules/module.py", line 547, in call result = self.forward(*input, **kwargs) File "/usr/local/lib/python3.7/site-packages/torch/nn/modules/loss.py", line 916, in forward ignore_index=self.ignore_index, reduction=self.reduction) File "/usr/local/lib/python3.7/site-packages/torch/nn/functional.py", line 1995, in cross_entropy return nll_loss(log_softmax(input, 1), target, weight, None, ignore_index, None, reduction) File "/usr/local/lib/python3.7/site-packages/torch/nn/functional.py", line 1824, in nll_loss ret = torch._C._nn.nll_loss(input, target, weight, _Reduction.get_enum(reduction), ignore_index) RuntimeError: Assertion `cur_target >= 0 && cur_target < n_classes' failed. at ../aten/src/THNN/generic/ClassNLLCriterion.c:94

system:MacOS

solver.py

cls_loss_real = CELoss(input=cls_real, target=speaker_idx_org)

# key issue: speaker_idx_or=tensor.Tensor([7,1,0,2])

yourlin avatar Sep 25 '19 10:09 yourlin

I may come a little late, so just comment here for anybody else encountering this issue later on.

The original problem I guess is you are using more than 4 number of speakers. That's why there is a number 7 there in speaker_idx_org, which is supposed to contain values ranging from 0-3 only.

To fix this, reducing the number of speakers you are using in preprocess.py step.

tranctan avatar May 08 '20 07:05 tranctan

I may come a little late, so just comment here for anybody else encountering this issue later on.

The original problem I guess is you are using more than 4 number of speakers. That's why there is a number 7 there in speaker_idx_org, which is supposed to contain values ranging from 0-3 only.

To fix this, reducing the number of speakers you are using in preprocess.py step.

Hi, sorry, just wanted to double check, so we cannot train this model for more than 4 speakers? Not having the complete understanding of the code yet but cannot it be modified for different number of speakers?

sainishalini avatar Oct 13 '22 02:10 sainishalini