asteroid.losses.sdr module¶
-
class
asteroid.losses.sdr.
PairwiseNegSDR
(sdr_type, zero_mean=True, take_log=True, EPS=1e-08)[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 : \((batch, nsrc, ...)\).
- targets: \((batch, nsrc, ...)\).
Returns: torch.Tensor
– with shape \((batch, nsrc, nsrc)\). 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', EPS=1e-08)[source]¶ Bases:
sphinx.ext.autodoc.importer._MockObject
Base class for single-source negative SI-SDR, SD-SDR and SNR.
Parameters: - sdr_type (str) – choose between
snr
for plain SNR,sisdr
for SI-SDR andsdsdr
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:
'none'
|'mean'
.'none'
: no reduction will be applied,'mean'
: the sum of the output will be divided by the number of elements in the output.
- Shape:
- est_targets : \((batch, time)\).
- targets: \((batch, time)\).
Returns: torch.Tensor
– with shape \((batch)\) ifreduction='none'
else [] scalar ifreduction='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.
- sdr_type (str) – choose between
-
class
asteroid.losses.sdr.
MultiSrcNegSDR
(sdr_type, zero_mean=True, take_log=True, EPS=1e-08)[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 : \((batch, nsrc, time)\).
- targets: \((batch, nsrc, time)\).
Returns: torch.Tensor
– with shape \((batch)\) ifreduction='none'
else [] scalar ifreduction='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.
pairwise_neg_sisdr
[source]¶ Base class for pairwise negative SI-SDR, SD-SDR and SNR on a batch.
Parameters: - Shape:
- est_targets : \((batch, nsrc, ...)\).
- targets: \((batch, nsrc, ...)\).
Returns: torch.Tensor
– with shape \((batch, nsrc, nsrc)\). 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_sdsdr
[source]¶ Base class for pairwise negative SI-SDR, SD-SDR and SNR on a batch.
Parameters: - Shape:
- est_targets : \((batch, nsrc, ...)\).
- targets: \((batch, nsrc, ...)\).
Returns: torch.Tensor
– with shape \((batch, nsrc, nsrc)\). 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
[source]¶ Base class for pairwise negative SI-SDR, SD-SDR and SNR on a batch.
Parameters: - Shape:
- est_targets : \((batch, nsrc, ...)\).
- targets: \((batch, nsrc, ...)\).
Returns: torch.Tensor
– with shape \((batch, nsrc, nsrc)\). 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_sisdr
[source]¶ Base class for single-source negative SI-SDR, SD-SDR and SNR.
Parameters: - sdr_type (str) – choose between
snr
for plain SNR,sisdr
for SI-SDR andsdsdr
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:
'none'
|'mean'
.'none'
: no reduction will be applied,'mean'
: the sum of the output will be divided by the number of elements in the output.
- Shape:
- est_targets : \((batch, time)\).
- targets: \((batch, time)\).
Returns: torch.Tensor
– with shape \((batch)\) ifreduction='none'
else [] scalar ifreduction='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.
- sdr_type (str) – choose between
-
asteroid.losses.sdr.
singlesrc_neg_sdsdr
[source]¶ Base class for single-source negative SI-SDR, SD-SDR and SNR.
Parameters: - sdr_type (str) – choose between
snr
for plain SNR,sisdr
for SI-SDR andsdsdr
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:
'none'
|'mean'
.'none'
: no reduction will be applied,'mean'
: the sum of the output will be divided by the number of elements in the output.
- Shape:
- est_targets : \((batch, time)\).
- targets: \((batch, time)\).
Returns: torch.Tensor
– with shape \((batch)\) ifreduction='none'
else [] scalar ifreduction='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.
- sdr_type (str) – choose between
-
asteroid.losses.sdr.
singlesrc_neg_snr
[source]¶ Base class for single-source negative SI-SDR, SD-SDR and SNR.
Parameters: - sdr_type (str) – choose between
snr
for plain SNR,sisdr
for SI-SDR andsdsdr
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:
'none'
|'mean'
.'none'
: no reduction will be applied,'mean'
: the sum of the output will be divided by the number of elements in the output.
- Shape:
- est_targets : \((batch, time)\).
- targets: \((batch, time)\).
Returns: torch.Tensor
– with shape \((batch)\) ifreduction='none'
else [] scalar ifreduction='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.
- sdr_type (str) – choose between
-
asteroid.losses.sdr.
multisrc_neg_sisdr
[source]¶ Base class for computing negative SI-SDR, SD-SDR and SNR for a given permutation of source and their estimates.
Parameters: - Shape:
- est_targets : \((batch, nsrc, time)\).
- targets: \((batch, nsrc, time)\).
Returns: torch.Tensor
– with shape \((batch)\) ifreduction='none'
else [] scalar ifreduction='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_sdsdr
[source]¶ Base class for computing negative SI-SDR, SD-SDR and SNR for a given permutation of source and their estimates.
Parameters: - Shape:
- est_targets : \((batch, nsrc, time)\).
- targets: \((batch, nsrc, time)\).
Returns: torch.Tensor
– with shape \((batch)\) ifreduction='none'
else [] scalar ifreduction='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
[source]¶ Base class for computing negative SI-SDR, SD-SDR and SNR for a given permutation of source and their estimates.
Parameters: - Shape:
- est_targets : \((batch, nsrc, time)\).
- targets: \((batch, nsrc, time)\).
Returns: torch.Tensor
– with shape \((batch)\) ifreduction='none'
else [] scalar ifreduction='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.