I am working on a multiclass segmentation problem. My target tensors are of the shape ([1,256,256]), with the unique values ([0.0000, 0.0039, 0.0078]). However, I want to convert the float values into long values as ([0, 1, 2]). When I use .long()
, all values turn to zeros.
below I have an example of my tensors:
([[0.0039, 0.0039, 0.0039, 0.0000, 0.0000],
[0.0039, 0.0039, 0.0039, 0.0000, 0.0000],
[0.0039, 0.0039, 0.0039, 0.0000, 0.0000],
[0.0000, 0.0078, 0.0078, 0.0078, 0.0000],
[0.0000, 0.0078, 0.0078, 0.0078, 0.0000]])
The desired output should be like the following:
([[1, 1, 1, 0, 0],
[1, 1, 1, 0, 0],
[1, 1, 1, 0, 0],
[0, 2, 2, 2, 0],
[0, 2, 2, 2, 0]])