nima.pytorch
nima.pytorch copied to clipboard
your emd loss seems wrong
Your implement is as below:
samplewise_emd = torch.sqrt(torch.mean(torch.pow(torch.abs(cdf_diff), 2))) return samplewise_emd.mean()
However, I think the correct implement should be:
emd = torch.sqrt(torch.mean(torch.pow(torch.abs(cdf_diff), 2), -1)) return emd.mean()
As https://github.com/titu1994/neural-image-assessment/blob/master/train_mobilenet.py mentioned,
def earth_mover_loss(y_true, y_pred): cdf_ytrue = K.cumsum(y_true, axis=-1) cdf_ypred = K.cumsum(y_pred, axis=-1) samplewise_emd = K.sqrt(K.mean(K.square(K.abs(cdf_ytrue - cdf_ypred)), axis=-1)) return K.mean(samplewise_emd)
Please check it!
I also found this problem... It turns out that it's not samplewise emd after applying mean function without setting dimension.