Torch.argmax return two values 0 and 2

my predicted segmentation outputs are 424256256, after torch.argmax, I want four,i.e. 0, 1,2,and 3 values in the tansor ,however, I just got two values. Anyone can help me ?

np.unique returns all unique values in the numpy array.
If there are only two unique values, you will just get these two.

I’m currently not sure, what your code is doing and what the dimensions refer to.
Could you explain your use case a bit?

my code is to segment sequence image ,the annotaiton is the ground truth, its shape is BatchframesHeightWidth. There are 4 objects to segment in each image, the outputs of predicted segmentation is BatchFramesChannelHeight*Width. By rights, the outputs maxed torch.argmax have 4 values , however, why are there only two values?

The output of torch.argmax has 4 dimensions, not necessarily 4 unique values.

Yes, I know the output of torch.argmax has 4 dimensions. I mean that the output maxed by torch.argmax should be consist of 4 different values, why only two values?

Thank you all the same


I think it has only two values because all the max are at either index 0 or 2 for your particular tensor outs. If you replace that with a completely random Tensor, you will (most likely) get all 4 values.