F.one_hot error: class values must be non-negative

hi,
i found an implementation of dice loss here, which has ignore_index option.
but it’s for image segmentation.
you should be able to reshape your model output and target for using it directly.(NxCxW —> NxCxWx1)