audio icon indicating copy to clipboard operation
audio copied to clipboard

TimeMasking does not work with unbatched input

Open gau-nernst opened this issue 2 years ago • 0 comments

🐛 Describe the bug

import torch
from torchaudio.transforms import TimeMasking, FrequencyMasking

x = torch.randn(80, 100)
FrequencyMasking(10)(x)  # this works
TimeMasking(10)(x)  # this doesn't

Error message

File [~/mambaforge/envs/dev/lib/python3.10/site-packages/torch/nn/modules/module.py:1501](https://file+.vscode-resource.vscode-cdn.net/home/ubuntu/code/speaker-age-estimation/~/mambaforge/envs/dev/lib/python3.10/site-packages/torch/nn/modules/module.py:1501), in Module._call_impl(self, *args, **kwargs)
   1496 # If we don't have any hooks, we want to skip the rest of the logic in
   1497 # this function, and just call forward.
   1498 if not (self._backward_hooks or self._backward_pre_hooks or self._forward_hooks or self._forward_pre_hooks
   1499         or _global_backward_pre_hooks or _global_backward_hooks
   1500         or _global_forward_hooks or _global_forward_pre_hooks):
-> 1501     return forward_call(*args, **kwargs)
   1502 # Do not call functions when jit is used
   1503 full_backward_hooks, non_full_backward_hooks = [], []

File [~/mambaforge/envs/dev/lib/python3.10/site-packages/torchaudio/transforms/_transforms.py:1227](https://file+.vscode-resource.vscode-cdn.net/home/ubuntu/code/speaker-age-estimation/~/mambaforge/envs/dev/lib/python3.10/site-packages/torchaudio/transforms/_transforms.py:1227), in _AxisMasking.forward(self, specgram, mask_value)
   1225     return F.mask_along_axis_iid(specgram, self.mask_param, mask_value, self.axis + 1, p=self.p)
   1226 else:
-> 1227     return F.mask_along_axis(specgram, self.mask_param, mask_value, self.axis, p=self.p)

File [~/mambaforge/envs/dev/lib/python3.10/site-packages/torchaudio/functional/functional.py:904](https://file+.vscode-resource.vscode-cdn.net/home/ubuntu/code/speaker-age-estimation/~/mambaforge/envs/dev/lib/python3.10/site-packages/torchaudio/functional/functional.py:904), in mask_along_axis(specgram, mask_param, mask_value, axis, p)
    901 if not 0.0 <= p <= 1.0:
    902     raise ValueError(f"The value of p must be between 0.0 and 1.0 ({p} given).")
--> 904 mask_param = _get_mask_param(mask_param, p, specgram.shape[axis])
    905 if mask_param < 1:
    906     return specgram

IndexError: tuple index out of range

To fix this, axis should be -1 (time masking) or -2 (frequency masking) instead.

Versions

Collecting environment information... PyTorch version: 2.0.1 Is debug build: False CUDA used to build PyTorch: 11.8 ROCM used to build PyTorch: N/A

OS: Ubuntu 20.04.6 LTS (x86_64) GCC version: (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0 Clang version: Could not collect CMake version: version 3.27.2 Libc version: glibc-2.31

Python version: 3.10.9 (main, Jan 11 2023, 15:21:40) [GCC 11.2.0] (64-bit runtime) Python platform: Linux-5.15.0-84-generic-x86_64-with-glibc2.31 Is CUDA available: True CUDA runtime version: Could not collect CUDA_MODULE_LOADING set to: LAZY GPU models and configuration: GPU 0: NVIDIA GeForce RTX 2070 SUPER Nvidia driver version: 530.30.02 cuDNN version: Could not collect HIP runtime version: N/A MIOpen runtime version: N/A Is XNNPACK available: True

CPU: Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit Byte Order: Little Endian Address sizes: 39 bits physical, 48 bits virtual CPU(s): 16 On-line CPU(s) list: 0-15 Thread(s) per core: 2 Core(s) per socket: 8 Socket(s): 1 NUMA node(s): 1 Vendor ID: GenuineIntel CPU family: 6 Model: 165 Model name: Intel(R) Core(TM) i7-10700 CPU @ 2.90GHz Stepping: 5 CPU MHz: 2900.000 CPU max MHz: 4800.0000 CPU min MHz: 800.0000 BogoMIPS: 5799.77 Virtualization: VT-x L1d cache: 256 KiB L1i cache: 256 KiB L2 cache: 2 MiB L3 cache: 16 MiB NUMA node0 CPU(s): 0-15 Vulnerability Gather data sampling: Mitigation; Microcode Vulnerability Itlb multihit: KVM: Mitigation: VMX disabled Vulnerability L1tf: Not affected Vulnerability Mds: Not affected Vulnerability Meltdown: Not affected Vulnerability Mmio stale data: Mitigation; Clear CPU buffers; SMT vulnerable Vulnerability Retbleed: Mitigation; Enhanced IBRS Vulnerability Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl and seccomp Vulnerability Spectre v1: Mitigation; usercopy/swapgs barriers and __user pointer sanitization Vulnerability Spectre v2: Mitigation; Enhanced IBRS, IBPB conditional, RSB filling, PBRSB-eIBRS SW sequence Vulnerability Srbds: Mitigation; Microcode Vulnerability Tsx async abort: Not affected Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault invpcid_single ssbd ibrs ibpb stibp ibrs_enhanced tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid mpx rdseed adx smap clflushopt intel_pt xsaveopt xsavec xgetbv1 xsaves dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp pku ospke md_clear flush_l1d arch_capabilities

Versions of relevant libraries: [pip3] ema-pytorch==0.2.3 [pip3] intel-extension-for-pytorch==2.0.100 [pip3] msgpack-numpy==0.4.8 [pip3] mypy-extensions==0.4.3 [pip3] numpy==1.23.5 [pip3] torch==2.0.1 [pip3] torchaudio==2.0.2 [pip3] torchcontrib==0.0.2 [pip3] triton==2.0.0 [conda] blas 1.0 mkl anaconda [conda] ema-pytorch 0.2.3 pypi_0 pypi [conda] intel-extension-for-pytorch 2.0.100 pypi_0 pypi [conda] mkl 2021.4.0 h06a4308_640 anaconda [conda] mkl-service 2.4.0 py310h7f8727e_0 anaconda [conda] mkl_fft 1.3.1 py310hd6ae3a3_0 anaconda [conda] mkl_random 1.2.2 py310h00e6091_0 anaconda [conda] msgpack-numpy 0.4.8 pypi_0 pypi [conda] numpy 1.23.5 py310hd5efca6_0 anaconda [conda] numpy-base 1.23.5 py310h8e6c178_0 anaconda [conda] pytorch 2.0.1 py3.10_cuda11.8_cudnn8.7.0_0 pytorch [conda] pytorch-cuda 11.8 h7e8668a_5 pytorch [conda] pytorch-mutex 1.0 cuda pytorch [conda] torchaudio 2.0.2 py310_cu118 pytorch [conda] torchcontrib 0.0.2 pypi_0 pypi [conda] torchtriton 2.0.0 py310 pytorch

gau-nernst avatar Sep 27 '23 09:09 gau-nernst