Skip to content

Conversation

@elanmart
Copy link
Contributor

This PR is supposed to fix #5296

New behaviour:

>>> import torch
>>> from torch.autograd import Variable
>>> import torch.nn.functional as F

>>> p = Variable(torch.randn(3, 3), requires_grad=True)
>>> y = Variable(torch.LongTensor([99, 100, 101]))
>>> l = F.cross_entropy(p, y, reduce=False)

RuntimeError: Target 100 out of bounds at /.../pytorch/aten/src/THNN/generic/ClassNLLCriterion.c:56

I'm not sure why *_no_reduce cuda kernels did not take n_classes as argument, was it meant to be that way?

@elanmart
Copy link
Contributor Author

@pytorchbot retest this please

@apaszke apaszke merged commit 6279367 into pytorch:master Feb 19, 2018
@apaszke
Copy link
Contributor

apaszke commented Feb 19, 2018

Thanks Marcin!

@elanmart elanmart deleted the fix-nll-criterion branch February 19, 2018 16:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

reduce=False --> No error for invalid labels

3 participants