Pytorch:One-hot编码

def mask2onehot(mask, num_classes): 
    # mask为灰度图,(H,W)→(K,H,W)
	_mask = [mask == i for i in range(num_classes)]
	return np.array(_mask).astype(np.uint8)

你可能感兴趣的:(代码,深度学习,神经网络)