import torch
from torchvision.utils import save_image
a=torch.randn(1,3,4,4)
b=torch.randn(1,3,4,4)
c=torch.randn(1,3,4,4)
d=a[0]
###直接创造了一个新的维度
e=torch.stack([a[0],b[0],c[0]],dim=0)
save_image(e, './hh.png')
# e=torch.cat([a[0],b[0],c[0]],dim=3)
print(e.shape)
这里注意 其中的a ,b,c 中的第一个维度必须是3 (rgb图),1(灰度图)