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: weight tensor should be defined either for all 19 classes or no classes but got weight tensor of shape: [1, 19] #26

Open
pomeloooo opened this issue Apr 12, 2023 · 3 comments

Comments

@pomeloooo
Copy link

RuntimeError: weight tensor should be defined either for all 19 classes or no classes but got weight tensor of shape: [1, 19]
how to solve

@magical1998
Copy link

I have same error,have u solve it?

@magical1998
Copy link

weight‘s shape should be (19,),not (1,19)
in train_SemantciKITTI.py,line 94

    class_weights = torch.from_numpy(train_dataset.get_class_weight()).float().cuda()
    class_weights=class_weights.squeeze(0)
    self.criterion = nn.CrossEntropyLoss(weight=class_weights, reduction='none')

@Wansit99
Copy link

Wansit99 commented Oct 16, 2023

weight‘s shape should be (19,),not (1,19) in train_SemantciKITTI.py,line 94

    class_weights = torch.from_numpy(train_dataset.get_class_weight()).float().cuda()
    class_weights=class_weights.squeeze(0)
    self.criterion = nn.CrossEntropyLoss(weight=class_weights, reduction='none')
    class_weights = torch.from_numpy(train_dataset.get_class_weight()).float().view(19).cuda() # change code to this can run

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