diff options
Diffstat (limited to 'learn_torch/basics/crossentropy_loss.py')
| -rw-r--r-- | learn_torch/basics/crossentropy_loss.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/learn_torch/basics/crossentropy_loss.py b/learn_torch/basics/crossentropy_loss.py new file mode 100644 index 0000000..67ccfa5 --- /dev/null +++ b/learn_torch/basics/crossentropy_loss.py @@ -0,0 +1,10 @@ + +from torch import nn +import torch + +if __name__ == '__main__': + input = torch.randn(3, 5) + target = torch.empty(3, dtype=torch.long).random_(5) + loss = nn.CrossEntropyLoss() + output = loss(input, target) + print(output)
\ No newline at end of file |
