Can't convert tensor with dtype float64 to torch.tensor.double

Hi,
i want to convert a numpy array into a tensor with dtype double because it gives me the following error when calling:

wav_stacked = torch.tensor(wav_stacked)
for wave in wav_stacked:
    torchaudio.transforms.MelSpectrogram(downsample_rate)(wave.double())
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py", line 722, in _call_impl
    result = self.forward(*input, **kwargs)
  File "/home/rudolpher68005/.local/lib/python3.8/site-packages/torchaudio/transforms.py", line 427, in forward
    mel_specgram = self.mel_scale(specgram)
  File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py", line 722, in _call_impl
    result = self.forward(*input, **kwargs)
  File "/home/rudolpher68005/.local/lib/python3.8/site-packages/torchaudio/transforms.py", line 260, in forward
    mel_specgram = torch.matmul(specgram.transpose(1, 2), self.fb).transpose(1, 2)
RuntimeError: Expected object of scalar type Double but got scalar type Float for argument #3 'mat2' in call to _th_addmm_out

How to convert the tensor so I can use it in the MelSpectogram function?

1 Like

The error was a little bit missleading. He expected a float not a double