From 92d3bc06bad13095df6515111bba45e73f701018 Mon Sep 17 00:00:00 2001 From: zhang Date: Sun, 24 Jul 2022 20:25:48 +0800 Subject: wordpiece --- learn_torch/basics/crossentropy_loss.py | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 learn_torch/basics/crossentropy_loss.py (limited to 'learn_torch/basics') 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 -- cgit v1.2.3