Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
yourlin opened this issue Sep 25, 2019 · 2 comments

Comments

@yourlin
Copy link

yourlin commented Sep 25, 2019

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])
@tranctan
Copy link

tranctan commented May 8, 2020

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.

@sainishalini
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants