@FaultyBagnose
I have asked this question at the time of using idea similar to yours.

  
    
    
    Merging classes of the output of the semantic segmentation module vision
  
  
    Hi all, 
My question is about the image segmentation task. 
I have a tensor with the size of (batch_size, 150, height, width) and the second number(150) corresponds to the number of classes. 
Now I want to merge those classes into 25 classes by summing their probabilities. 
First of all, is this procedure correct? It seems it should be, for example I want to merge river and lake into one class. 
Note: I have the source and target indexes to be merged. For example: 
target=[1, 2]
source= [[3,4],
…
  


I hope it helps.