Hi,
I want to write a custom loss function so first i tried to mimic built-in MSE loss as below but it gave much lower losses than built-in function (nn.MSELoss()). It is important to learn like below how to extract (i,j)th data and do something with it like calculating gradient on x-direction etc. Can you please explain where am i doing wrong? Also, i have 3 output channels and i wonder how nn.MSELoss() calculates loss (calculates separately and then adds together?) Thanks!
    def custom(self, pred, truth):      
        for j in range(1,255):
            for i in range(1,255):
                loss = torch.mean((truth[:,:, i, j] - pred[:,:, i, j])**2)
        return loss
                                                        
        self.custom.to(self.device)