Hello,I am using a Unet network and need to write a loss function myself, this loss function needs to involve calculations that convert to numpy.


Summary
def my_mse_loss(input, target):
    a = input.data[0].numpy().flatten()
    b = target.data[0].numpy().flatten()
    loss = 0
    for i in range(len(a)):
        x = a[i]-b[i]
        loss += abs(x**2)
    return torch.Tensor(loss) / input.data.nelement()


Or can you write an example for me?More detailed.