Solved by ptrblck in post #2 
              
              
                If you are working on a multi-class segmentation use case, nn.CrossEntropyLoss would be the preferred loss function. 
Your error is raised by a sklearn metric method and is unrelated to the criterion in PyTorch.