PyTorch - shivamvats/notes GitHub Wiki
Tensor
tensor.tolist()
: return the tensor as a (nested) list. moves the Tensor to the CPU if necessary.tensor.item()
: access the value of a Tensor object with only one element.tensor.squeeze()
: return a view of the tensor with all dims with size 1 removed.tensor.unsqueeze(dim)
: add a new dimension atdim
.