我正在try 按in_inds对Signal_Matrix进行切片,但我想uint8索引是不同的.有人能解释一下它是如何工作的吗?
signal_matrix = torch.tensor(
[[0, 0, 1, 1],
[0, 0, 0, 0],
[0, 0, 1, 1],
[0, 1, 1, 0],
[1, 0, 1, 0],
[0, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0]], dtype=torch.uint8)
in_inds = torch.tensor(
[[ 0, 2, 3],
[ 1, 2, 4],
[ 0, 0, 0]][::-1], dtype= torch.uint8
)
out_inds = torch.tensor(
[ 5, 6, 7], dtype= torch.uint8)
op_inds = torch.tensor(
[ [1, 1, 1, 1],
[0, 0, 0, 0],
[2, 2, 2, 2]], dtype= torch.uint8)
in_signals = signal_matrix[in_inds]
IndexError: The shape of the mask [3, 3] at index 0 does not match the shape of the indexed tensor [9, 4] at index 0
个
总的来说,我预计会是这样的.同样的结果也适用于int32.
tensor([[[0, 0, 1, 1],
[0, 0, 1, 1],
[0, 0, 1, 1]],
[[0, 0, 0, 0],
[0, 0, 1, 1],
[1, 0, 1, 0]],
[[0, 0, 1, 1],
[0, 0, 1, 1],
[0, 1, 1, 0]]], dtype=torch.int32)