torch.empty would be faster as it doesn’t need to initialize the memory.
However, using torch.zeros might avoid running into this error, but you would add the “zero label” to the invalid colors, which might create invalid targets.