torch.unbind(input, dim=0) → tuple
参数解释:input为tensor,dim为要去除的维度
函数作用:去除tensor的一个维度,返回沿着给定维度的元组
举例:
txt = torch.randn(3,4,5) y = torch.unbind(txt, dim=1) print(y)
运行结果如下:
说明:去除维度为dimension 1,返回沿着维度1切片的四个tensor,y为元组形式
torch.unbind(input, dim=0) → tuple
参数解释:input为tensor,dim为要去除的维度
函数作用:去除tensor的一个维度,返回沿着给定维度的元组
举例:
txt = torch.randn(3,4,5) y = torch.unbind(txt, dim=1) print(y)
运行结果如下:
说明:去除维度为dimension 1,返回沿着维度1切片的四个tensor,y为元组形式