Created
December 28, 2020 08:01
-
-
Save InnovArul/58bccf265adfaf8e0adfa71b6e554e43 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torch | |
import torch.nn.functional as F | |
is_cuda = True | |
input = torch.randn(1, 19, 32, 64, requires_grad=True) | |
target = torch.randint(22, size=(1,32,64,)) | |
print(input.dim()) | |
print("number of out-of-bound targets", (target > 18).sum()) | |
if is_cuda: | |
input = input.cuda() | |
target = target.cuda() | |
out = F.cross_entropy(input, target, weight=None, ignore_index=255, reduction='none') | |
print(out) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment