csteinmetz1 / auraloss

Collection of audio-focused loss functions in PyTorch
Apache License 2.0
695 stars 66 forks source link

Feat: Reduction option for SumAndDifferenceSTFTLoss #50

Open zaptrem opened 1 year ago

zaptrem commented 1 year ago

I'm currently trying to apply a different scalar to the loss of each element in a batch , but SumAndDifferenceSTFTLoss doesn't have the option to return element-wise losses (in most loss functions this is reduction="none"). Is this feasible to add?

csteinmetz1 commented 1 year ago

Thanks @zaptrem.

After taking a look into this I see why it wasn't implemented in the first place. Handling operation for reduction = "none" is non-trivial for any loss that has multiple sub-components. We have been thinking for a while to provide a different interface for computing losses that would involve a Transform and a Distance which would make this behavior more clear. We might have to wait for this interface in order to support this feature. However, this use-case provides more reasoning to work on this.

I will keep this issue open for now, but follow #16 if you are interested.