1 Acknowledgements
Thanks to the official documentation provided by PyTorch,
Link: https://pytorch.org/docs/stable/tensors.html
2 How to create a Tensor
2.1 Use torch.tensor() to directly create Tensor
The sample code is as follows:
torch.tensor([[1, 2, 3], [4, 5, 6]])
2.2 How to create a Tensor as a parameter
(Tensor created by default method, attribute requires_grad=False)
The sample code is as follows:
x = torch.tensor([[1.], [-1.]], requires_grad=True)
3 Index of Tensor in PyTorch
3.2 You can use boolTensor to "filter" Tensor
boolTensor has a "filtering" effect on Tensor. The effect of the example is shown in the figure below.