切块操作split and chunk

https://blog.csdn.net/foneone/article/details/103875250

  • torch.split(待操作tensor,切块后形状,dim)
  • torch.chunk(待操作tensor, 切成多少块, dim)
t = torch.rand(10,3)
t1 = t.split(2,dim=0) # tuple (5,) t1[0]:torch.Size([2, 3])
t2 = t.chunk(2,dim=0)   # tuple (2,) t2[0]:torch.Size([5, 3])

你可能感兴趣的:(切块操作split and chunk)