pytorch中对tensor操作:分片、索引、压缩、扩充、交换维度、拼接、切割、变形
pytorch中对tensor的分片、索引操作根据维度提取子集
根据维度提取子集
原始数据情况
import torch
a = torch.tensor([[1,2,3,4],[5,6,7,8],[9,10,11,12]], dtype=float)
print(a) #原始数据情况
#下面#开头的是输出
#tensor([[ 1., 2., 3., 4.],
# [ 5., 6., 7., 8.],
# [ 9., 10., 11., 12.]], dtype
原创
2020-11-20 12:48:06 ·
15679 阅读 ·
2 评论