这是这个问题的后续问题。我想在 pytorch 中做同样的事情。是否有可能做到这一点?如果是,如何?
import torch
image = torch.tensor([[246, 50, 101], [116, 1, 113], [187, 110, 64]])
iy = torch.tensor([[1, 0, 2], [1, 0, 2], [2, 2, 2]])
ix = torch.tensor([[0, 2, 1], [1, 2, 0], [0, 1, 2]])
warped_image = torch.zeros(size=image.shape)
Run Code Online (Sandbox Code Playgroud)
我需要类似的东西torch.add.at(warped_image, (iy, ix), image)给输出
[[ 0. 0. 51.]
[246. 116. 0.]
[300. 211. 64.]]
Run Code Online (Sandbox Code Playgroud)
请注意,位于(0,1)和的索引(1,1)指向相同的位置(0,2)。所以,我想要warped_image[0,2] = image[0,1] + image[1,1] = 51.