Skip to content

your emd loss seems wrong #24

@HuaZheLei

Description

@HuaZheLei

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions