Pytorch Tips
Here is some tips for pytorch1.x.
tensor
1 | import torch |
note: torch.tensor will auto guess the type; torch.Tensor is same with dtype=float32
1 | x = torch.tensor([1]) |
sort tensor and reverse sort
1 | # sort |
you can also use .index_select()
1 | # the following part is a special case |