Make targets in semantic segmentation?

Hi,

I downloaded PASCAL-VOC 2012 datasets and I want to train my semantic segmentation model.
Surely, outputs size of my model are

(Batch_size, 22, W, H) # where 22 is number of classes in dataset(21 classes + 1 background)

Then, I noticed that I have to make target map (i.e. ground truth segmentation) to same size pixel-wise one-hot vectors. But, I cannot find efficient way to do so.(Iā€™m a novice of deep learning :frowning: ) Can anyone help me??