Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test additional losses and move them to a meaningful place #33

Open
einbandi opened this issue Aug 4, 2022 · 0 comments
Open

Test additional losses and move them to a meaningful place #33

einbandi opened this issue Aug 4, 2022 · 0 comments

Comments

@einbandi
Copy link
Collaborator

einbandi commented Aug 4, 2022

Currently kullback_leibler_divergence and cross_entropy_loss are located in paradime.loss. Should they be moved to paradime.routines instead? What about the following losses from the old ptsne.py file:

def kullback_leibler_loss(p, q, eps=1.0e-7):
    eps = torch.tensor(eps, dtype=p.dtype)
    kl_matr = torch.mul(p, torch.log(p + eps) - torch.log(q + eps))
    kl_matr.fill_diagonal_(0.)    
    return torch.sum(kl_matr)

def kullback_leibler_reverse_loss(p, q, eps=1.0e-7):
    return kullback_leibler_loss(q, p, eps)


def jensen_shannon_loss(p, q, eps=1.0e-7):
    m = 0.5*(p+q)
    return 0.5*kullback_leibler_loss(p, m, eps) + 0.5*kullback_leibler_loss(q, m, eps)

def frobenius_loss(p, q):
    return torch.pow(p - q, 2).sum()

def total_variational_loss(p, q):
    return torch.abs(p-q).sum()
@einbandi einbandi changed the title Test additional losses ad move them to a meaningful place Test additional losses and move them to a meaningful place Aug 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant