Map the value in a tensor using dictionary

Hi, I have a 4x4 tensor, for example [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]] and I also have a mapping dict, like {4: 5, 7: 10, 13: 10, 15: 1, 16: 1}. Is there any way to map the value in the tensor using this dictionary efficiently?

2 Likes