asteroid.losses.sdr module¶
-
class
asteroid.losses.sdr.
MultiSrcNegSDR
(sdr_type, zero_mean=True, take_log=True)[source]¶ Bases:
sphinx.ext.autodoc.importer._MockObject
Base class for computing negative SI-SDR, SD-SDR and SNR for a given permutation of source and their estimates.
Parameters: - Shape:
- est_targets (
torch.Tensor
): Expected shape [batch, time]. - Batch of target estimates.
- targets (
torch.Tensor
): Expected shape [batch, time]. - Batch of training targets.
- est_targets (
Returns: torch.Tensor
–- with shape [batch] if reduction=’none’ else
- [] scalar if reduction=’mean’.
Examples
>>> import torch >>> from asteroid.losses import PITLossWrapper >>> targets = torch.randn(10, 2, 32000) >>> est_targets = torch.randn(10, 2, 32000) >>> loss_func = PITLossWrapper(MultiSrcNegSDR("sisdr"), >>> pit_from='perm_avg') >>> loss = loss_func(est_targets, targets)
References
[1] Le Roux, Jonathan, et al. “SDR half-baked or well done.” IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP) 2019.
-
class
asteroid.losses.sdr.
NoSrcSDR
(*args, **kwargs)[source]¶ Bases:
asteroid.losses.sdr.SingleSrcNegSDR
,asteroid.utils.deprecation_utils.DeprecationMixin
-
class
asteroid.losses.sdr.
NonPitSDR
(*args, **kwargs)[source]¶ Bases:
asteroid.losses.sdr.MultiSrcNegSDR
,asteroid.utils.deprecation_utils.DeprecationMixin
-
class
asteroid.losses.sdr.
PairwiseNegSDR
(sdr_type, zero_mean=True, take_log=True)[source]¶ Bases:
sphinx.ext.autodoc.importer._MockObject
Base class for pairwise negative SI-SDR, SD-SDR and SNR on a batch.
Parameters: - Shape:
- est_targets (
torch.Tensor
): Expected shape - [batch, n_src, time]. Batch of target estimates.
- targets (
torch.Tensor
): Expected shape - [batch, n_src, time]. Batch of training targets.
- est_targets (
Returns: torch.Tensor
– with shape [batch, n_src, n_src]. Pairwise losses.Examples
>>> import torch >>> from asteroid.losses import PITLossWrapper >>> targets = torch.randn(10, 2, 32000) >>> est_targets = torch.randn(10, 2, 32000) >>> loss_func = PITLossWrapper(PairwiseNegSDR("sisdr"), >>> pit_from='pairwise') >>> loss = loss_func(est_targets, targets)
References
[1] Le Roux, Jonathan, et al. “SDR half-baked or well done.” IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP) 2019.
-
class
asteroid.losses.sdr.
SingleSrcNegSDR
(sdr_type, zero_mean=True, take_log=True, reduction='none')[source]¶ Bases:
sphinx.ext.autodoc.importer._MockObject
Base class for single-source negative SI-SDR, SD-SDR and SNR.
Parameters: - sdr_type (string) – choose between “snr” for plain SNR, “sisdr” for SI-SDR and “sdsdr” for SD-SDR [1].
- zero_mean (bool, optional) – by default it zero mean the target and estimate before computing the loss.
- take_log (bool, optional) – by default the log10 of sdr is returned.
- reduction (string, optional) – Specifies the reduction to apply to the output:
- | 'mean'. 'none' ('none') – no reduction will be applied,
- 'mean' – the sum of the output will be divided by the number of
- in the output. (elements) –
- Shape:
- est_targets (
torch.Tensor
): Expected shape [batch, time]. - Batch of target estimates.
- targets (
torch.Tensor
): Expected shape [batch, time]. - Batch of training targets.
- est_targets (
Returns: torch.Tensor
–- with shape [batch] if reduction=’none’ else
- [] scalar if reduction=’mean’.
Examples
>>> import torch >>> from asteroid.losses import PITLossWrapper >>> targets = torch.randn(10, 2, 32000) >>> est_targets = torch.randn(10, 2, 32000) >>> loss_func = PITLossWrapper(SingleSrcNegSDR("sisdr"), >>> pit_from='pw_pt') >>> loss = loss_func(est_targets, targets)
References
[1] Le Roux, Jonathan, et al. “SDR half-baked or well done.” IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP) 2019.
-
asteroid.losses.sdr.
multisrc_neg_sdsdr
¶ Base class for computing negative SI-SDR, SD-SDR and SNR for a given permutation of source and their estimates.
Parameters: - Shape:
- est_targets (
torch.Tensor
): Expected shape [batch, time]. - Batch of target estimates.
- targets (
torch.Tensor
): Expected shape [batch, time]. - Batch of training targets.
- est_targets (
Returns: torch.Tensor
–- with shape [batch] if reduction=’none’ else
- [] scalar if reduction=’mean’.
Examples
>>> import torch >>> from asteroid.losses import PITLossWrapper >>> targets = torch.randn(10, 2, 32000) >>> est_targets = torch.randn(10, 2, 32000) >>> loss_func = PITLossWrapper(MultiSrcNegSDR("sisdr"), >>> pit_from='perm_avg') >>> loss = loss_func(est_targets, targets)
References
[1] Le Roux, Jonathan, et al. “SDR half-baked or well done.” IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP) 2019.
-
asteroid.losses.sdr.
multisrc_neg_sisdr
¶ Base class for computing negative SI-SDR, SD-SDR and SNR for a given permutation of source and their estimates.
Parameters: - Shape:
- est_targets (
torch.Tensor
): Expected shape [batch, time]. - Batch of target estimates.
- targets (
torch.Tensor
): Expected shape [batch, time]. - Batch of training targets.
- est_targets (
Returns: torch.Tensor
–- with shape [batch] if reduction=’none’ else
- [] scalar if reduction=’mean’.
Examples
>>> import torch >>> from asteroid.losses import PITLossWrapper >>> targets = torch.randn(10, 2, 32000) >>> est_targets = torch.randn(10, 2, 32000) >>> loss_func = PITLossWrapper(MultiSrcNegSDR("sisdr"), >>> pit_from='perm_avg') >>> loss = loss_func(est_targets, targets)
References
[1] Le Roux, Jonathan, et al. “SDR half-baked or well done.” IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP) 2019.
-
asteroid.losses.sdr.
multisrc_neg_snr
¶ Base class for computing negative SI-SDR, SD-SDR and SNR for a given permutation of source and their estimates.
Parameters: - Shape:
- est_targets (
torch.Tensor
): Expected shape [batch, time]. - Batch of target estimates.
- targets (
torch.Tensor
): Expected shape [batch, time]. - Batch of training targets.
- est_targets (
Returns: torch.Tensor
–- with shape [batch] if reduction=’none’ else
- [] scalar if reduction=’mean’.
Examples
>>> import torch >>> from asteroid.losses import PITLossWrapper >>> targets = torch.randn(10, 2, 32000) >>> est_targets = torch.randn(10, 2, 32000) >>> loss_func = PITLossWrapper(MultiSrcNegSDR("sisdr"), >>> pit_from='perm_avg') >>> loss = loss_func(est_targets, targets)
References
[1] Le Roux, Jonathan, et al. “SDR half-baked or well done.” IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP) 2019.
-
asteroid.losses.sdr.
nonpit_neg_sdsdr
¶ Base class for computing negative SI-SDR, SD-SDR and SNR for a given permutation of source and their estimates.
Parameters: - Shape:
- est_targets (
torch.Tensor
): Expected shape [batch, time]. - Batch of target estimates.
- targets (
torch.Tensor
): Expected shape [batch, time]. - Batch of training targets.
- est_targets (
Returns: torch.Tensor
–- with shape [batch] if reduction=’none’ else
- [] scalar if reduction=’mean’.
Examples
>>> import torch >>> from asteroid.losses import PITLossWrapper >>> targets = torch.randn(10, 2, 32000) >>> est_targets = torch.randn(10, 2, 32000) >>> loss_func = PITLossWrapper(MultiSrcNegSDR("sisdr"), >>> pit_from='perm_avg') >>> loss = loss_func(est_targets, targets)
References
[1] Le Roux, Jonathan, et al. “SDR half-baked or well done.” IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP) 2019.
-
asteroid.losses.sdr.
nonpit_neg_sisdr
¶ Base class for computing negative SI-SDR, SD-SDR and SNR for a given permutation of source and their estimates.
Parameters: - Shape:
- est_targets (
torch.Tensor
): Expected shape [batch, time]. - Batch of target estimates.
- targets (
torch.Tensor
): Expected shape [batch, time]. - Batch of training targets.
- est_targets (
Returns: torch.Tensor
–- with shape [batch] if reduction=’none’ else
- [] scalar if reduction=’mean’.
Examples
>>> import torch >>> from asteroid.losses import PITLossWrapper >>> targets = torch.randn(10, 2, 32000) >>> est_targets = torch.randn(10, 2, 32000) >>> loss_func = PITLossWrapper(MultiSrcNegSDR("sisdr"), >>> pit_from='perm_avg') >>> loss = loss_func(est_targets, targets)
References
[1] Le Roux, Jonathan, et al. “SDR half-baked or well done.” IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP) 2019.
-
asteroid.losses.sdr.
nonpit_neg_snr
¶ Base class for computing negative SI-SDR, SD-SDR and SNR for a given permutation of source and their estimates.
Parameters: - Shape:
- est_targets (
torch.Tensor
): Expected shape [batch, time]. - Batch of target estimates.
- targets (
torch.Tensor
): Expected shape [batch, time]. - Batch of training targets.
- est_targets (
Returns: torch.Tensor
–- with shape [batch] if reduction=’none’ else
- [] scalar if reduction=’mean’.
Examples
>>> import torch >>> from asteroid.losses import PITLossWrapper >>> targets = torch.randn(10, 2, 32000) >>> est_targets = torch.randn(10, 2, 32000) >>> loss_func = PITLossWrapper(MultiSrcNegSDR("sisdr"), >>> pit_from='perm_avg') >>> loss = loss_func(est_targets, targets)
References
[1] Le Roux, Jonathan, et al. “SDR half-baked or well done.” IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP) 2019.
-
asteroid.losses.sdr.
nosrc_neg_sdsdr
¶ Base class for single-source negative SI-SDR, SD-SDR and SNR.
Parameters: - sdr_type (string) – choose between “snr” for plain SNR, “sisdr” for SI-SDR and “sdsdr” for SD-SDR [1].
- zero_mean (bool, optional) – by default it zero mean the target and estimate before computing the loss.
- take_log (bool, optional) – by default the log10 of sdr is returned.
- reduction (string, optional) – Specifies the reduction to apply to the output:
- | 'mean'. 'none' ('none') – no reduction will be applied,
- 'mean' – the sum of the output will be divided by the number of
- in the output. (elements) –
- Shape:
- est_targets (
torch.Tensor
): Expected shape [batch, time]. - Batch of target estimates.
- targets (
torch.Tensor
): Expected shape [batch, time]. - Batch of training targets.
- est_targets (
Returns: torch.Tensor
–- with shape [batch] if reduction=’none’ else
- [] scalar if reduction=’mean’.
Examples
>>> import torch >>> from asteroid.losses import PITLossWrapper >>> targets = torch.randn(10, 2, 32000) >>> est_targets = torch.randn(10, 2, 32000) >>> loss_func = PITLossWrapper(SingleSrcNegSDR("sisdr"), >>> pit_from='pw_pt') >>> loss = loss_func(est_targets, targets)
References
[1] Le Roux, Jonathan, et al. “SDR half-baked or well done.” IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP) 2019.
-
asteroid.losses.sdr.
nosrc_neg_sisdr
¶ Base class for single-source negative SI-SDR, SD-SDR and SNR.
Parameters: - sdr_type (string) – choose between “snr” for plain SNR, “sisdr” for SI-SDR and “sdsdr” for SD-SDR [1].
- zero_mean (bool, optional) – by default it zero mean the target and estimate before computing the loss.
- take_log (bool, optional) – by default the log10 of sdr is returned.
- reduction (string, optional) – Specifies the reduction to apply to the output:
- | 'mean'. 'none' ('none') – no reduction will be applied,
- 'mean' – the sum of the output will be divided by the number of
- in the output. (elements) –
- Shape:
- est_targets (
torch.Tensor
): Expected shape [batch, time]. - Batch of target estimates.
- targets (
torch.Tensor
): Expected shape [batch, time]. - Batch of training targets.
- est_targets (
Returns: torch.Tensor
–- with shape [batch] if reduction=’none’ else
- [] scalar if reduction=’mean’.
Examples
>>> import torch >>> from asteroid.losses import PITLossWrapper >>> targets = torch.randn(10, 2, 32000) >>> est_targets = torch.randn(10, 2, 32000) >>> loss_func = PITLossWrapper(SingleSrcNegSDR("sisdr"), >>> pit_from='pw_pt') >>> loss = loss_func(est_targets, targets)
References
[1] Le Roux, Jonathan, et al. “SDR half-baked or well done.” IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP) 2019.
-
asteroid.losses.sdr.
nosrc_neg_snr
¶ Base class for single-source negative SI-SDR, SD-SDR and SNR.
Parameters: - sdr_type (string) – choose between “snr” for plain SNR, “sisdr” for SI-SDR and “sdsdr” for SD-SDR [1].
- zero_mean (bool, optional) – by default it zero mean the target and estimate before computing the loss.
- take_log (bool, optional) – by default the log10 of sdr is returned.
- reduction (string, optional) – Specifies the reduction to apply to the output:
- | 'mean'. 'none' ('none') – no reduction will be applied,
- 'mean' – the sum of the output will be divided by the number of
- in the output. (elements) –
- Shape:
- est_targets (
torch.Tensor
): Expected shape [batch, time]. - Batch of target estimates.
- targets (
torch.Tensor
): Expected shape [batch, time]. - Batch of training targets.
- est_targets (
Returns: torch.Tensor
–- with shape [batch] if reduction=’none’ else
- [] scalar if reduction=’mean’.
Examples
>>> import torch >>> from asteroid.losses import PITLossWrapper >>> targets = torch.randn(10, 2, 32000) >>> est_targets = torch.randn(10, 2, 32000) >>> loss_func = PITLossWrapper(SingleSrcNegSDR("sisdr"), >>> pit_from='pw_pt') >>> loss = loss_func(est_targets, targets)
References
[1] Le Roux, Jonathan, et al. “SDR half-baked or well done.” IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP) 2019.
-
asteroid.losses.sdr.
pairwise_neg_sdsdr
¶ Base class for pairwise negative SI-SDR, SD-SDR and SNR on a batch.
Parameters: - Shape:
- est_targets (
torch.Tensor
): Expected shape - [batch, n_src, time]. Batch of target estimates.
- targets (
torch.Tensor
): Expected shape - [batch, n_src, time]. Batch of training targets.
- est_targets (
Returns: torch.Tensor
– with shape [batch, n_src, n_src]. Pairwise losses.Examples
>>> import torch >>> from asteroid.losses import PITLossWrapper >>> targets = torch.randn(10, 2, 32000) >>> est_targets = torch.randn(10, 2, 32000) >>> loss_func = PITLossWrapper(PairwiseNegSDR("sisdr"), >>> pit_from='pairwise') >>> loss = loss_func(est_targets, targets)
References
[1] Le Roux, Jonathan, et al. “SDR half-baked or well done.” IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP) 2019.
-
asteroid.losses.sdr.
pairwise_neg_sisdr
¶ Base class for pairwise negative SI-SDR, SD-SDR and SNR on a batch.
Parameters: - Shape:
- est_targets (
torch.Tensor
): Expected shape - [batch, n_src, time]. Batch of target estimates.
- targets (
torch.Tensor
): Expected shape - [batch, n_src, time]. Batch of training targets.
- est_targets (
Returns: torch.Tensor
– with shape [batch, n_src, n_src]. Pairwise losses.Examples
>>> import torch >>> from asteroid.losses import PITLossWrapper >>> targets = torch.randn(10, 2, 32000) >>> est_targets = torch.randn(10, 2, 32000) >>> loss_func = PITLossWrapper(PairwiseNegSDR("sisdr"), >>> pit_from='pairwise') >>> loss = loss_func(est_targets, targets)
References
[1] Le Roux, Jonathan, et al. “SDR half-baked or well done.” IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP) 2019.
-
asteroid.losses.sdr.
pairwise_neg_snr
¶ Base class for pairwise negative SI-SDR, SD-SDR and SNR on a batch.
Parameters: - Shape:
- est_targets (
torch.Tensor
): Expected shape - [batch, n_src, time]. Batch of target estimates.
- targets (
torch.Tensor
): Expected shape - [batch, n_src, time]. Batch of training targets.
- est_targets (
Returns: torch.Tensor
– with shape [batch, n_src, n_src]. Pairwise losses.Examples
>>> import torch >>> from asteroid.losses import PITLossWrapper >>> targets = torch.randn(10, 2, 32000) >>> est_targets = torch.randn(10, 2, 32000) >>> loss_func = PITLossWrapper(PairwiseNegSDR("sisdr"), >>> pit_from='pairwise') >>> loss = loss_func(est_targets, targets)
References
[1] Le Roux, Jonathan, et al. “SDR half-baked or well done.” IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP) 2019.
-
asteroid.losses.sdr.
singlesrc_neg_sdsdr
¶ Base class for single-source negative SI-SDR, SD-SDR and SNR.
Parameters: - sdr_type (string) – choose between “snr” for plain SNR, “sisdr” for SI-SDR and “sdsdr” for SD-SDR [1].
- zero_mean (bool, optional) – by default it zero mean the target and estimate before computing the loss.
- take_log (bool, optional) – by default the log10 of sdr is returned.
- reduction (string, optional) – Specifies the reduction to apply to the output:
- | 'mean'. 'none' ('none') – no reduction will be applied,
- 'mean' – the sum of the output will be divided by the number of
- in the output. (elements) –
- Shape:
- est_targets (
torch.Tensor
): Expected shape [batch, time]. - Batch of target estimates.
- targets (
torch.Tensor
): Expected shape [batch, time]. - Batch of training targets.
- est_targets (
Returns: torch.Tensor
–- with shape [batch] if reduction=’none’ else
- [] scalar if reduction=’mean’.
Examples
>>> import torch >>> from asteroid.losses import PITLossWrapper >>> targets = torch.randn(10, 2, 32000) >>> est_targets = torch.randn(10, 2, 32000) >>> loss_func = PITLossWrapper(SingleSrcNegSDR("sisdr"), >>> pit_from='pw_pt') >>> loss = loss_func(est_targets, targets)
References
[1] Le Roux, Jonathan, et al. “SDR half-baked or well done.” IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP) 2019.
-
asteroid.losses.sdr.
singlesrc_neg_sisdr
¶ Base class for single-source negative SI-SDR, SD-SDR and SNR.
Parameters: - sdr_type (string) – choose between “snr” for plain SNR, “sisdr” for SI-SDR and “sdsdr” for SD-SDR [1].
- zero_mean (bool, optional) – by default it zero mean the target and estimate before computing the loss.
- take_log (bool, optional) – by default the log10 of sdr is returned.
- reduction (string, optional) – Specifies the reduction to apply to the output:
- | 'mean'. 'none' ('none') – no reduction will be applied,
- 'mean' – the sum of the output will be divided by the number of
- in the output. (elements) –
- Shape:
- est_targets (
torch.Tensor
): Expected shape [batch, time]. - Batch of target estimates.
- targets (
torch.Tensor
): Expected shape [batch, time]. - Batch of training targets.
- est_targets (
Returns: torch.Tensor
–- with shape [batch] if reduction=’none’ else
- [] scalar if reduction=’mean’.
Examples
>>> import torch >>> from asteroid.losses import PITLossWrapper >>> targets = torch.randn(10, 2, 32000) >>> est_targets = torch.randn(10, 2, 32000) >>> loss_func = PITLossWrapper(SingleSrcNegSDR("sisdr"), >>> pit_from='pw_pt') >>> loss = loss_func(est_targets, targets)
References
[1] Le Roux, Jonathan, et al. “SDR half-baked or well done.” IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP) 2019.
-
asteroid.losses.sdr.
singlesrc_neg_snr
¶ Base class for single-source negative SI-SDR, SD-SDR and SNR.
Parameters: - sdr_type (string) – choose between “snr” for plain SNR, “sisdr” for SI-SDR and “sdsdr” for SD-SDR [1].
- zero_mean (bool, optional) – by default it zero mean the target and estimate before computing the loss.
- take_log (bool, optional) – by default the log10 of sdr is returned.
- reduction (string, optional) – Specifies the reduction to apply to the output:
- | 'mean'. 'none' ('none') – no reduction will be applied,
- 'mean' – the sum of the output will be divided by the number of
- in the output. (elements) –
- Shape:
- est_targets (
torch.Tensor
): Expected shape [batch, time]. - Batch of target estimates.
- targets (
torch.Tensor
): Expected shape [batch, time]. - Batch of training targets.
- est_targets (
Returns: torch.Tensor
–- with shape [batch] if reduction=’none’ else
- [] scalar if reduction=’mean’.
Examples
>>> import torch >>> from asteroid.losses import PITLossWrapper >>> targets = torch.randn(10, 2, 32000) >>> est_targets = torch.randn(10, 2, 32000) >>> loss_func = PITLossWrapper(SingleSrcNegSDR("sisdr"), >>> pit_from='pw_pt') >>> loss = loss_func(est_targets, targets)
References
[1] Le Roux, Jonathan, et al. “SDR half-baked or well done.” IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP) 2019.