How to realize the function of looking up table with PyTorch in a most efficient way?

Hi guys,
I am studying about semantic segmentation these days.
And I need to transform a grey image into a matrix with the value of trainId, as
微信图片_20200223164520
So, I want to use PyTorch to realize the function of looking up table in a most efficient way.
And your suggestion and idea will be appreciated!

Hi,

I don’t think any pytorch-specific feature is needed here. You can use regular python dictionaries to do this :slight_smile:

1 Like

Thanks for your kind response.
And I just wanted to make sure whether there is a PyTorch function can help me realize a looking up table function.

1 Like