pytorch / audio

Data manipulation and transformation for audio signal processing, powered by PyTorch
https://pytorch.org/audio
BSD 2-Clause "Simplified" License
2.54k stars 654 forks source link

Randomness in torch.compliance.kaldi.fbanks #574

Closed dros1986 closed 4 years ago

dros1986 commented 4 years ago

🐛 Bug

Fbanks computed on same waveform change from one run to another.

SOLVED: My bad, I didn't know that the dither parameter, if different from zero, introduces noise. Thank you for your help.

To Reproduce

Steps to reproduce the behavior:

Compute the filterbanks on same waveform multiple times and observe the absolute difference.

import torch
import torchaudio
import torchaudio.compliance.kaldi as kaldi

waveform, sample_rate = torchaudio.load('00001.wav')

for i in range(5):
    feat1 = kaldi.fbank(waveform=waveform, sample_frequency=sample_rate, num_mel_bins=40)
    feat2 = kaldi.fbank(waveform=waveform, sample_frequency=sample_rate, num_mel_bins=40)
    print(torch.abs(feat1-feat2).sum())

returns:

tensor(21854.6953)
tensor(21868.1934)
tensor(21707.9492)
tensor(21902.4062)
tensor(21755.6875)

Expected behavior

The difference among one run to another should be zero.

Environment

Tested on three different computers.

Computer 1

Collecting environment information... PyTorch version: 1.4.0 Is debug build: No CUDA used to build PyTorch: 10.1

OS: Ubuntu 18.04.3 LTS GCC version: (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0 CMake version: version 3.10.2

Python version: 3.7 Is CUDA available: Yes CUDA runtime version: 10.0.130 GPU models and configuration: GPU 0: TITAN Xp Nvidia driver version: 418.56 cuDNN version: Could not collect

Versions of relevant libraries: [pip3] numpy==1.18.1 [pip3] numpydoc==0.9.2 [pip3] torch==1.4.0 [pip3] torchaudio==0.4.0 [pip3] torchstat==0.0.7 [pip3] torchsummary==1.5.1 [pip3] torchvision==0.5.0 [conda] cudatoolkit 10.1.243 h6bb024c_0
[conda] mkl 2019.5 281 conda-forge [conda] mkl-service 2.3.0 py37h516909a_0 conda-forge [conda] mkl_fft 1.1.0 py37hc1659b7_1 conda-forge [conda] mkl_random 1.1.0 py37hb3f55d8_0 conda-forge [conda] numpy 1.18.1 py37h95a1406_0 conda-forge [conda] numpy-base 1.18.1 py37h2f8d375_1
[conda] numpydoc 0.9.2 py_0 conda-forge [conda] torch 1.4.0 pypi_0 pypi [conda] torchaudio 0.4.0 pypi_0 pypi [conda] torchstat 0.0.7 pypi_0 pypi [conda] torchsummary 1.5.1 pypi_0 pypi [conda] torchvision 0.5.0 pypi_0 pypi

Computer 2

Collecting environment information... PyTorch version: 1.4.0 Is debug build: No CUDA used to build PyTorch: 10.1

OS: Ubuntu 16.04.6 LTS GCC version: (Ubuntu 6.3.0-21ubuntu1~16.04.york0) 6.3.0 20170628 CMake version: version 3.5.1

Python version: 3.7 Is CUDA available: Yes CUDA runtime version: Could not collect GPU models and configuration: GPU 0: TITAN Xp Nvidia driver version: 418.39 cuDNN version: /usr/lib/x86_64-linux-gnu/libcudnn.so.7.0.5

Versions of relevant libraries: [pip3] numpy==1.14.5 [conda] mkl 2019.4 243
[conda] mkl-service 2.3.0 py37h516909a_0 conda-forge [conda] mkl_fft 1.1.0 py37hc1659b7_1 conda-forge [conda] mkl_random 1.1.0 py37hb3f55d8_0 conda-forge [conda] numpy 1.18.1 py37h95a1406_0 conda-forge [conda] numpy-base 1.18.1 py37h2f8d375_1
[conda] numpydoc 0.9.2 py_0 conda-forge [conda] torch 1.4.0 pypi_0 pypi [conda] torchaudio 0.4.0 pypi_0 pypi [conda] torchfile 0.1.0 py_0 conda-forge [conda] torchsummary 1.5.1 pypi_0 pypi [conda] torchvision 0.5.0 pypi_0 pypi

Computer 3

Collecting environment information... PyTorch version: 1.4.0 Is debug build: No CUDA used to build PyTorch: 10.1

OS: Ubuntu 18.04.4 LTS GCC version: (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0 CMake version: Could not collect

Python version: 3.7 Is CUDA available: Yes CUDA runtime version: Could not collect GPU models and configuration: GPU 0: GeForce 940M Nvidia driver version: 430.64 cuDNN version: Could not collect

Versions of relevant libraries: [pip] numpy==1.18.1 [pip] numpydoc==0.9.2 [pip] torch==1.4.0 [pip] torchaudio==0.4.0 [pip] torchstat==0.0.7 [pip] torchsummary==1.5.1 [pip] torchvision==0.5.0 [conda] _pytorch_select 0.1 cpu_0
[conda] blas 1.0 mkl conda-forge [conda] cudatoolkit 10.1.243 h6bb024c_0
[conda] libblas 3.8.0 14_mkl conda-forge [conda] libcblas 3.8.0 14_mkl conda-forge [conda] liblapack 3.8.0 14_mkl conda-forge [conda] liblapacke 3.8.0 14_mkl conda-forge [conda] mkl 2019.4 243
[conda] mkl-service 2.3.0 py37h516909a_0 conda-forge [conda] mkl_fft 1.1.0 py37hc1659b7_1 conda-forge [conda] mkl_random 1.1.0 py37hb3f55d8_0 conda-forge [conda] numpy 1.18.1 pypi_0 pypi [conda] numpydoc 0.9.2 py_0 conda-forge [conda] pytorch 1.4.0 py3.7_cuda10.1.243_cudnn7.6.3_0 pytorch [conda] torch 1.4.0 pypi_0 pypi [conda] torchaudio 0.4.0 pypi_0 pypi [conda] torchstat 0.0.7 pypi_0 pypi [conda] torchsummary 1.5.1 pypi_0 pypi [conda] torchvision 0.5.0 pypi_0 pypi

mthrok commented 4 years ago

Hi

Using test/assets/kaldi_file_8000.wav, I got the following result.

tensor(0.)
tensor(0.)
tensor(0.)
tensor(0.)
tensor(0.)

I assume you found the issue somewhere else.

dros1986 commented 4 years ago

Hi

Using test/assets/kaldi_file_8000.wav, I got the following result.

tensor(0.)
tensor(0.)
tensor(0.)
tensor(0.)
tensor(0.)

I assume you found the issue somewhere else.

My bad, I didn't know that the dither parameter, if different from zero, introduces noise. Thank you for answering.