八阿哥图鉴
收集写代码过程中的bug们
Dr. 卷心菜
PhD在读|音频信号处理|机器学习|音乐信号处理
展开
-
Pytorch训练CRNN输出为NaN
记录一个非常隐蔽pytorch训练audio相关的Bug。原创 2022-11-25 13:43:55 · 1179 阅读 · 1 评论 -
Pytorch报错TypeError : __init__() takes 1 positional argument but 2 were given 原因及解决方法
在使用sigmoid函数时报这个错误,看到了有个博客说是因为类的调用出现错误,但是不知道怎么改。错误写法x = nn.Sigmoid(x)正确写法outlayer = nn.Sigmoid() # 需要先对类实例化,才能调用x = outlayer(x)官网例子:m = nn.Sigmoid()loss = nn.BCELoss()input = torch.randn(3, requires_grad=True)target = torch.empty(3).random_(2)原创 2021-03-24 14:44:22 · 16818 阅读 · 5 评论 -
Pytorch报错 CUDA error: device-side assert triggered
错误信息:RuntimeError: CUDA error: device-side assert triggered/pytorch/aten/src/THCUNN/ClassNLLCriterion.cu:108: cunn_ClassNLLCriterion_updateOutput_kernel: block: [0,0,0], thread: [1,0,0] Assertion `t >= 0 && t < n_classes` failed./pytorch/a原创 2020-12-29 15:22:39 · 5174 阅读 · 0 评论 -
Scipy读取wav格式音频报错:Unsupported bit depth: the wav file has 24-bit data
代码from scipy.io import wavfilesr, y = wavfile.read('audio/XXX.wav')错误信息~/anaconda3/lib/python3.7/site-packages/scipy/io/wavfile.py in read(filename, mmap) 255 if bit_depth not in (8, 16, 32, 64, 96, 128): 256原创 2020-12-17 10:50:13 · 1157 阅读 · 0 评论 -
Python音频转成numpy数组:numpy.frombuffer报错ValueError: buffer size must be a multiple of element size
使用背景:导入音频信号,下面代码段最后一句报错import waveimport numpy as npf = wave.open(wav_path)params = f.getparams()nchannels, sampwidth, framerate, nframes = params[:4]# 声道数; 量化位数(byte); 采样频率; 采样点数str_audio =...原创 2020-03-11 22:38:34 · 11318 阅读 · 3 评论 -
VSCode中报错 E501:Line too long (83>79 characters)
1. 错误描述在VS Code中编辑Python代码时flake8报错:Line too long (83>79 characters)(E501)flake8是python的错误提示工具,类似的还有pep8等,有时候这种工具提示的太严格了也会让人很心累,下面提供两种方法修改。2. 打开setting.json:方法一:将限制条件放宽如上错误是因为flake8要求一行不超过79个字符,我们可以人为设定到120个:"python.linting.flake8Args": ["--max-原创 2020-11-03 18:15:06 · 11093 阅读 · 9 评论 -
jupyter报错AttributeError: type object IOLoop has no attribute initialized
问题描述:打开jupyter notebook时,报错Traceback (most recent call last): File "E:\software\Anaconda\Scripts\jupyter-notebook-script.py", line 3, in <module> import notebook.notebookapp File "E:\software\Anaconda\lib\site-packages\notebook\notebookapp.原创 2020-10-21 13:25:20 · 6496 阅读 · 5 评论 -
Fatal Python error: Py_Initialize: can‘t initialize sys standard streams
问题描述:Windows 10Python 3.6在终端输入任何指令都报如下错误:Fatal Python error: Py_Initialize: can't initialize sys standard streamsLookupError: unknown encoding: 65001解决方法:在终端输入set PYTHONIOENCODING=utf-8问题原因:Windows cmd命令行编码问题导致python无法使用。参考:https://stackoverf原创 2020-10-21 13:43:09 · 5102 阅读 · 4 评论 -
Python - TypeError: object of type NoneType has no len() 解决方法
定义的函数没有返回值,加上返回值即可参考:https://stackoverflow.com/questions/48096547/python-typeerror-object-of-type-nonetype-has-no-len原创 2019-03-28 11:18:58 · 56212 阅读 · 2 评论 -
scipy.signal.lfilter报错 ValueError: could not convert b, a, and x to a common type
问题描述:在用scipy.signal.lfilter实现滤波器时报错:ValueError: could not convert b, a, and x to a common type问题出在这一行:x = scipy.signal.lfilter(1, a, y)原因分析:Scipy要求分子和分母都要是数组类型,而1是整型Parameters:b array_likeThe numerator coefficient vector in a 1-D sequence.a arr原创 2020-09-17 21:31:50 · 900 阅读 · 0 评论 -
audioread.exceptions.NoBackendError in librosa
文章目录Problem: NoBackendErrorSolutionThis is the real solution to NoBackendError despite a backend (specifically FFmpeg) being installedReferencesProblem: NoBackendErrorI’m trying to load “mp3” files in librosa by the following line.data, _ = librosa.core原创 2020-11-05 14:39:47 · 7485 阅读 · 0 评论 -
librosa.util.exceptions.ParameterError: data must be floating-point 终极解决方法
librosa提取melspectrogram代码audio, _ = librosa.load(file_path, sr=16000, mono=True)mel_spec = librosa.feature.melspectrogram(y=audio, sr=sample_rate, n_mels=n_mels)报错内容这样会显示第二句报错:librosa.util.exceptions.ParameterError: data must be floating-point解决方法原创 2020-11-05 16:30:33 · 3679 阅读 · 0 评论