【发布时间】:2021-07-14 00:16:24
【问题描述】:
我在 pytorch 中使用 torch.rot90 随机旋转 3D 图像,但这会以相同的方式旋转批次中的所有图像。我想找到一种可区分的方法来随机旋转不同轴上的每个图像。 这是将每个图像旋转到相同方向的代码:
#x = next batch
k = torch.randint(0, 4, (1,)).item()
dims = [0,0]
dims[0] = dims[1] = torch.randint(2, 5, (1,))
while dims[0] == dims[1]:#this makes sure the two axes aren't the same
dims[1] = torch.randint(2, 5, (1,))
x = torch.rot90(x, k, dims)
# x is now a batch of 3D images that have all been rotated in the same random orientation
【问题讨论】:
标签: neural-network pytorch conv-neural-network backpropagation