KEMBAR78
torchaudio.transforms.Spectrogram with power=1 can easily NaN · Issue #993 · pytorch/audio · GitHub
Skip to content

torchaudio.transforms.Spectrogram with power=1 can easily NaN #993

@gibiansky

Description

@gibiansky

🐛 Bug

If you use STFT through Spectrogram, with power=1, you can easily get a NaN. If your spectrogram square magnitude underflows to zero, you end up taking backprop of sqrt(0), which leads to a NaN.

To Reproduce

Steps to reproduce the behavior:

  1. Use torchaudio.transforms.Spectrogram, set power=1, do a backward pass.

Expected behavior

There should be a configurable epsilon to clamp the input to sqrt, otherwise users have to use torch.stft directly or use other workarounds (such as power=2).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions