0

How to use cross entropy for float images and labels? I'm studying Semantic segmentation with Cityscapes data.

When I use

torchivision.transfrom.ToTensor()

My Images and labels data are transform the range from [0~255] to [0~1]. Because I used ToTensor().

Then I passed images to a model, I got prediction (Batch X class X W X H) from.

After that, I want to use CrossEntropy to get loss.
The labels is (Batch X W X H), range [0~1]
The prediction is (Batch X Class X W X H), range[-inf ~ +inf (somewhere)]

But I got an error, Those input should be Tensor.long.

If I cast theos labels to Tensor.Long, labels should be all 0.

What shoud I do???

The cityscapes should be treated ignore index. Cross entropy has Ignore index. But the labels are [0~1] range.

1 Answers1

0

Solve by myself. In Segmentation, No use Normalize and toTensor.

Thanks.