Pytorch 扩展Tensor维度、压缩Tensor维度

注:维度参数为1、dim为索引位置

一、扩展维度

data1 = data.unsqueeze(dim=n)

二、压缩维度

data2 = data.squeeze(dim=n)

posted @ 2021-12-25 15:04  微笑黎  阅读(181)  评论(0)    收藏  举报