小bugs搜集和解决方法,亲测有效(2022-2023)
有些小bugs几行指令就能解决,写太多不好,这里就进行一个2022-2023这段时间的bugs collection和solution。
Deep Learning
How to make really empty tensor?
a = nn.Torch([])
b = torch.empty(2,3)
for i in rang(3):a = torch.cat(a, b, dim=0)
Mismatched attribute type in ’ : value’ ==> Context: Bad node spec for node. Name: OpType: Constant
pip uninstall onnx; pip install onnx==1.11
参考:
onnx
Try running yolov3_onnx sample
Can’t pickle local object 'MiniImagenet.init..
windows不支持:
No, it is not supported on Windows. The reason is that multiprocessing lib doesn’t have it implemented on Windows. There are some alternatives like dill that can pickle more objects.
类似问题:
Can’t pickle local object ‘DataLoader.__init__.<locals>.<lambda>'
参考资料:
Can’t pickle local object ‘DataLoader.init..’
Python 3.11 + pytorch in win11 has error
Use python 3.10.
Freeze layer bugs
Model.named_parameters()会忽略掉一些参数,比如:
Conv1.Bn.running_mean
Conv1.Bn.running_var
Conv1.Bn.num_batches_tracked
解决方法,用model.state_dict():
for k, v in model.state_dict().items():print kprint type(v)
参考资料:
Model.named_parameters() will lose some layer modules
Python
Import “imgaug.augmenters” could not be resolved PylancereportMissingImports
解决方法:
conda install imgaug
Cannot import name ‘_registerMatType’ from ‘cv2.cv2’ #1494
在cmd等命令窗口卸载imagua。Uninstall imagua in user folder by cmd.
pip uninstall imagua
The frame append method is deprecated use pandas.concat instead
从
self.F1ScoreDF = self.F1ScoreDF.append(pd.DataFrame(TCnn.F1Score).T)
改成
self.F1ScoreDF = pd.concat([self.F1ScoreDF, pd.DataFrame(TCnn.F1Score).T])
set_yticks does not show up
Map类型的数据不要用来做label。It is nothing about figure size, but just the label names are stored by map object, which is illegal.
ax.set_yticks(np.arange(data.shape[0]), labels=ClassNames)ClassNames = map(str.upper, opt.class_names)
to
ClassNames = list(map(str.upper, opt.class_names))
Anaconda
OMP: Error #15: Initializing libiomp5md.dll, but found libiomp5md.dll already initialized.
OMP: Hint This means that multiple copies of the OpenMP runtime have been linked into the program. That is dangerous, since it can degrade performance or cause
incorrect results. The best thing to do is to ensure that only a single OpenMP runtime is linked into the process, e.g. by avoiding static linking of the OpenMP runtime in any library. As an unsafe, unsupported, undocumented workaround you can set the environment variable KMP_DUPLICATE_LIB_OK=TRUE to allow the program
to continue to execute, but that may cause crashes or silently produce incorrect results. For more information, please see http://www.intel.com/software/products/support/.
解决方法:
将mkl在anaconda得navigator删除。
remove mkl in anaconda navigator。
Anaconda libstdc++.so.6: version `GLIBCXX_3.4.20’ not found
conda update libstdcxx-ng
参考资料:
Anaconda libstdc++.so.6: version `GLIBCXX_3.4.20’ not found
sklearn for conda
conda install -c conda-forge scikit-learn
GitHub
fatal: unable to access Connection was reset in connection to github.com:443
git config --global --get http.proxy
参考:
Getting Git to work with a proxy server - fails with “Request timed out”
! [remote rejected] main -> main (Internal Server Error)
! [remote rejected] main -> main (Internal Server Error)
error: failed to push some refs to 'https://github.com/anthonyweidai/Advanced_SPL_Classification.git'
解决方法:
git config --bool core.bare true
参考:
Git push error ‘[remote rejected] master -> master (branch is currently checked out)’
fatal: this operation must be run in a work tree
git config --unsetcore.bare
参考:
[FIXED] fatal: this operation must be run in a work tree
The term ‘conda’ is not recognized as the name of a cmdlet
The term 'conda' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again
解决方法:
Add
S:\ProgramData\Anaconda3
S:\ProgramData\Anaconda3\Scripts
S:\ProgramData\Anaconda3\Library\bin
to environment.
Or install anaconda with adding path environment option.
Reboot computer.
conda init powershell
conda init cmd.exe
Git upper case lower case
git config --global core.ignorecase false
参考资料:
How do you change the capitalization of filenames in Git?
Others
the system cannot find the path specified
Click the file inside the zip, and then unzip inside files directly.
‘npm’ is not recognized as an internal or external command
下载Nodejs,download Nodejs.