- 创建张量
torch.tensor(list,dtype)
torch.arange(start,end,step)
torch.linespace(start,end,len)
torch.zeros(tuple)
torch.zeros_like(tensor)
torch.ones(tuple)
torch.ones_like(tensor)
torch.fill(tensor,value)
torch.rand()
torch.randn()
torch.normal()
torch.randperm(int)
torch.eye(a,b)
torch.diag(tensor)
- 索引切片
tensor[int]
tensor[a,b]=tensor[a][b]
tensor[a:b:c,d:e:f]
torch.index_select(tensor,dim,index)
torch.masked_select(tensor,判断条件)
torch.where(判断,value1,value2)
torch.index_fill(tensor,dim,index,value)
torch.masked_fill(tensor,判断条件,value)
- 维度变换
torch.reshape(tensor,list)
torch.squeeze(tensor)
torch.unsqueeze(tensor,axis)
torch.transpose(tensor,a,b)
- 合并分割
torch.cat()
torch.stack()
torch.split(tensor,split_size_or_sections,dim)