question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItĀ collects links to all the places you might be looking at while hunting down a tough bug.

And, if youā€™re still stuck at the end, weā€™re happy to hop on a call to see how we can help out.

get_metrics returns a result not consistent with PITLossWrapper

See original GitHub issue

šŸ› Bug

get_metrics returns a result not consistent with PITLossWrapper

To Reproduce

from asteroid.metrics import get_metrics
import torch
from asteroid.losses import PITLossWrapper,pairwise_neg_sisdr

while True:
    sources = torch.randn(1, 2, 64000)
    est_sources = torch.randn(1, 2, 64000)
    mixture = torch.randn(64000)


    m = get_metrics(mixture.numpy(), sources.numpy()[0, ], est_sources.numpy()[0, ], compute_permutation=True, metrics_list=['si_sdr'])
    print(m, "   compute_permutation=True")
    m = get_metrics(mixture.numpy(), sources.numpy()[0, ], est_sources.numpy()[0, ], compute_permutation=False, metrics_list=['si_sdr'])
    print(m, "   compute_permutation=False")

    asteroid_pit = PITLossWrapper(pairwise_neg_sisdr, pit_from='pw_mtx')
    loss_val = asteroid_pit(est_sources, sources)
    print(-loss_val.item(), "   PITLossWrapper(pairwise_neg_sisdr, pit_from='pw_mtx')")
    print()

My Results

{'input_si_sdr': -64.04041290283203, 'si_sdr': -57.542795181274414}    compute_permutation=True
{'input_si_sdr': -64.04041290283203, 'si_sdr': -51.0589714050293}    compute_permutation=False 
-51.0589714050293    PITLossWrapper(pairwise_neg_sisdr, pit_from='pw_mtx')

{'input_si_sdr': -61.0158634185791, 'si_sdr': -61.65677261352539}    compute_permutation=True  
{'input_si_sdr': -61.0158634185791, 'si_sdr': -45.297006607055664}    compute_permutation=False
-45.29700469970703    PITLossWrapper(pairwise_neg_sisdr, pit_from='pw_mtx')

{'input_si_sdr': -47.6236515045166, 'si_sdr': -52.26988410949707}    compute_permutation=True 
{'input_si_sdr': -47.6236515045166, 'si_sdr': -62.26840019226074}    compute_permutation=False
-52.2698860168457    PITLossWrapper(pairwise_neg_sisdr, pit_from='pw_mtx')

{'input_si_sdr': -58.1720085144043, 'si_sdr': -57.48860168457031}    compute_permutation=True 
{'input_si_sdr': -58.1720085144043, 'si_sdr': -57.48860168457031}    compute_permutation=False
-50.58534240722656    PITLossWrapper(pairwise_neg_sisdr, pit_from='pw_mtx')

Expected behavior

The si_sdr of compute_permutation=True should be the same with PITLossWrapper(pairwise_neg_sisdr, pit_from='pw_mtx')?

The si_sdr of compute_permutation=True should always be higher than compute_permutation=False?

Additional info

I donā€™t know if itā€™s my misunderstanding or not.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:14 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
quancscommented, Jun 1, 2021

Thatā€™s what I expected, and this is a good news: the metrics is good, and the only problem is regarding the permutations.

We usually donā€™t compute it in the recipes, because we reorder before, but we should definitely fix it. Would you want to have a look? Iā€™m writing my PhD these days, I donā€™t have much time for that.

OKay, I will try, but I cannot guarantee it will be fixed soon. Iā€™m writing my dissertation proposalā€¦

0reactions
quancscommented, Jun 2, 2021

I donā€™t think there is a bug there, itā€™s reliable. Do you want to submit a PR to raise an error for compute_permutation=True? That would be cool.

Thank you. You can fix it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Losses & Metrics ā€” asteroid 0.6.1dev documentation
Permutation invariant reorderer. Only returns the reordered estimates. See :py:class:asteroid.losses.PITLossWrapper . forward (est_targets, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found