KEMBAR78
Add warning about complex tensor to spectrogram by mthrok · Pull Request #1431 · pytorch/audio · GitHub
Skip to content

Conversation

mthrok
Copy link
Contributor

@mthrok mthrok commented Apr 5, 2021

Follow-up of #1366 .
cc. @anjali411
part of #1337

Replaced by #1445

warnings.warn(
"spectrogram now supports returning native complex tensor "
"when `power=None` by setting `return_complex=True`. "
"Currently, the function returns pseudo complex type (..., 2) by default, "

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"Currently, the function returns pseudo complex type (..., 2) by default, "
"Currently, this function returns pseudo complex type (..., 2) by default, "

"when `power=None` by setting `return_complex=True`. "
"Currently, the function returns pseudo complex type (..., 2) by default, "
"but this will change in the future and `return_complex` would be set to True by default. "
"Please refer to https://github.com/pytorch/audio/issues/1337 for the detail.")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"Please refer to https://github.com/pytorch/audio/issues/1337 for the detail.")
"Please refer to https://github.com/pytorch/audio/issues/1337 for more details about the migration plan.")

Fourier bins, and time is the number of window hops (n_frame).
"""
if power is None and not return_complex:
warnings.warn(
Copy link

@anjali411 anjali411 Apr 5, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should explicitly mention it's a deprecation warning:

"Deprecation warning: In a future TorchAudio release, `spectrogram` ",
"will no longer return tensors of pseudo complex type (..., 2) by default. ",
"Instead, `return_complex` will be set to `True` by default and spectrogram",
"would return native complex tensors by default."

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually even better, we could use https://docs.python.org/3/library/exceptions.html#DeprecationWarning

warnings.warn(msg, category=DeprecationWarning) where msg equals

"In a future TorchAudio release, `spectrogram` ",
"will no longer return tensors of pseudo complex type (..., 2) by default. ",
"Instead, `return_complex` will be set to `True` by default and spectrogram",
"would return native complex tensors by default."

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@anjali411
I do not have a preference here but, according to this comment by @gchanan, PyTorch uses UserWarning for deprecation, so in torchaudio we used UserWarning.

However, I see mixed usage in pytorch.
https://github.com/pytorch/pytorch/search?q=DeprecationWarning
https://github.com/pytorch/pytorch/blob/c371542efc31b1abfe6f388042aa3ab0cef935f2/torch/hub.py#L512

Copy link
Contributor Author

@mthrok mthrok Apr 7, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@anjali411 Do we want to deprecate the pseudo complex in the upcoming release?

The planned migrations phases are as following and I was thinking to deprecate the native complex type in phase 2.

  1. Add support for native complex type (upcoming release)
  2. Switch to native complex type by default
  3. Remove pseudo complex type

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I gave some thoughts on this and now I think it makes more sense to give heads up on deprecation prior to defaulting native complex type.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup agreed! let's make a note of that in the main tracker issue so that we don't forget

@mthrok
Copy link
Contributor Author

mthrok commented Apr 9, 2021

See #1445

@mthrok mthrok closed this Apr 9, 2021
@mthrok mthrok deleted the warn-spectrogram-complex branch April 13, 2021 15:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants