Created
December 9, 2015 09:25
-
-
Save minhlab/5bfa451eaa49c5aa58dc to your computer and use it in GitHub Desktop.
We should avoid index x into itself since doing so risks collision.
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
th> i = torch.LongTensor(10) | |
[0.0001s] | |
th> i:random(10) | |
8 | |
2 | |
2 | |
2 | |
7 | |
2 | |
4 | |
10 | |
5 | |
10 | |
[torch.LongTensor of size 10] | |
th> x:uniform() | |
0.8798 | |
0.2683 | |
0.2149 | |
0.5722 | |
0.6652 | |
0.5961 | |
0.6528 | |
0.0276 | |
0.4766 | |
0.6235 | |
[torch.DoubleTensor of size 10] | |
[0.0001s] | |
th> x2=x:index(1, i) | |
[0.0000s] | |
th> x:index(x, 1, i) | |
8 | |
2 | |
2 | |
2 | |
7 | |
2 | |
4 | |
10 | |
5 | |
10 | |
[torch.LongTensor of size 10] | |
[0.0001s] | |
th> x:eq(x2) | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
0 | |
1 | |
0 | |
1 | |
[torch.ByteTensor of size 10] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment