我一直在试图找出如何在张量中调整批次、通道、高度和宽度维度的大小。目前,我可以调整通道、高度和宽度尺寸,但批次尺寸保持不变
x = torch.ones(3,4,64,64)
x = F.interpolate(x.unsqueeze(0), size=(3,4,4), mode="trilinear").squeeze(0)
x.size() # (3,3,4,4) # batch dimension has not been resized.
# I need x to be resized so that it has a size of: (1,3,4,4)
# Is this a good idea?
x = x.permute(1,0,2,3)
x = F.interpolate(x.unsqueeze(0), size=(1, x.size(2), x.size(3)), mode="trilinear").squeeze(0)
x = x.permute(1,0,2,3)
x.size() # (1,3,4,4)
我应该排列张量来调整批次维度的大小吗?或者以某种方式对其进行迭代
这似乎让我可以调整批次维度的大小:
相关问题 更多 >
编程相关推荐