I have two tensors, the first one A
has a shape (B, N, 2)
, where N
stands for the number and 2
stands for the indices. Another one B
has a shape (B, N, 3)
, 3
is the specified values. I want to scatter B
's values corresponding to A
to a shape (B, H, W, 3)
. For example,
B = [[[1 1]
[0 2]]
[[1 1]
[1 2]]]
A = [[[1 1 1]
[2 0 1]]
[[0 9 8]
[9 1 2]]]
Through my thought, the final tensor with shape (2, 2, 2, 3)
would be
[[
[
[0, 0, 0],
[0, 0, 0],
[2, 0, 1]
],
[
[0, 0, 0],
[1, 1, 1],
[0, 0, 0]
]
], [
[
[0, 0, 0],
[0, 0, 0],
[0, 0, 0]
],
[
[0, 0, 0],
[0, 9, 8],
[9, 1, 2]
]
]]
Except for those indices specified in A
, other positions will be set to zeros. Are there any solutions to tackle this problem?