Created
July 21, 2020 12:47
-
-
Save mandubian/0f0894b6ac72812a39d682423a151811 to your computer and use it in GitHub Desktop.
This file contains 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 | |
# a Float tensor | |
>>> a = torch.tensor([[0, 0], [1, 1], [2, 2]], dtype=torch.float) | |
>>> a | |
tensor([[0., 0.], | |
[1., 1.], | |
[2., 2.]]) | |
# a Long tensor | |
>>> b = torch.tensor([[3], [4], [5]], dtype=torch.long) | |
>>> b | |
tensor([[3], | |
[4], | |
[5]]) | |
# Torch on float vs long tensors => WTF? | |
>>> torch.cat([a, b], dim=1) | |
tensor([[0.0000e+00, 0.0000e+00, 4.2039e-45], | |
[1.0000e+00, 1.0000e+00, 0.0000e+00], | |
[2.0000e+00, 2.0000e+00, 5.6052e-45]]) | |
# Torch on float vs float tensors => WTF? | |
>>> torch.cat([a, b.float()], dim=1) | |
tensor([[0., 0., 3.], | |
[1., 1., 4.], | |
[2., 2., 5.]]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment