Your current output tensor contains logits for a single class (check the size of dim1, which is 1 in your case and which is nb_classes in my case), so you would have to make sure the output has the shape [batch_size, nb_classes, depth, height, width].