torch.Tensor — PyTorch 1.10.1 documentation
pytorch.org › docs › stableFor example, torch.FloatTensor.abs_() computes the absolute value in-place and returns the modified tensor, while torch.FloatTensor.abs() computes the result in a new tensor. Note To change an existing tensor’s torch.device and/or torch.dtype , consider using to() method on the tensor.
python - Unique values in PyTorch tensor - Stack Overflow
https://stackoverflow.com/questions/4499332409.07.2017 · get common items between two tensors with torch.eq () fetch indices and concatenate tensors finally get common items via torch.unique: import torch as pt a = pt.tensor ( [1,2,3,2,3,4,3,4,5,6]) b = pt.tensor ( [7,2,3,2,7,4,9,4,9,8]) equal_data = pt.eq (a, b) pt.unique (pt.cat ( [a [equal_data],b [equal_data]])) Share Improve this answer