『Pytorch』PyTorch basics

1. Basic data: Tensor

1. Tensor combination and block

combination

Refers to a combination of different operations Tensoradd up, there are torch.cat()and torch.stack()two functions.

  • torch.cat(): That is concatenate, it refers to splicing along a certain dimension of the existing data. After the operation, the total dimensionality of the data remains unchanged. When splicing, except for the splicing dimension, other dimensions must be the same.
  • torch.stack(): Refers to the newly added dimension, which is superimposed according to the specified dimension.

Block

Block operation is opposite to a combination, refers Tensordivided into different sub Tensor, main torch.chunk()and torch.split()two functions.

  • torch.chunk(): Need to specify the number of blocks
  • torch.split(): Need to specify the size of each block

2. Tensor index and deformation

Guess you like

Origin blog.csdn.net/libo1004/article/details/111183593