I want to weight each pixel to compute my loss function. Now first I calculate cross entropy loss with reduce = False for the images and then multiply by weights and then calculate the mean. If I choose all the weights as 1, I should get a consistent result. But its not the case.

Hi, I think it’s a matter of digging into source code. If I’m not wrong it performs sample-wise mean. Later it averages. In addition, weights are multiplied batch-wise (I think). How are you setting those parameters?