python/pytorch编程debug
- 1.调用函数返回`‘None’type`
- 2.使用matplotlib.pyplot 保存图片为空
- 3.`TypeError: Image data of dtype object cannot be converted to float`
- 4.`RuntimeError: stack expects each tensor to be equal size, but got [2, 5] at entry 0 and [1, 5] at entry 1`
- 5.`torch.gather() RuntimeError: Size does not match at dimension 0 get 2 vs 1`
- 6.`TypeError: list indices must be integers or slices, not tuple`
- 7.发生异常: `ModuleNotFoundError No module named '***'`
- 8. `ValueError: could not convert string to float: 'r'`
- 9. `RuntimeError: CUDA error: an illegal memory access was encountered`
- 10. `UnpicklingError: A load persistent id instruction was encountered,but no persistent_load function was specified.`
- 11.`TypeError: new() received an invalid combination of arguments - got (numpy.float64, int), but expected one of: * (*, torch.device device)`
- 12.`EmptyDataError: No columns to parse from file`
- 13.`AttributeError: predict_proba is not available when probability=False`
- 14.`(null): can't open file '***': [Errno 2] No such file or directory`
- 15.`OSError: [WinError 123]` 文件名、目录名或卷标语法不正确。
- 16.`TypeError: **func() got an unexpected keyword argument ***`
- 17.`RuntimeError: pad should be smaller than half of kernel size, but got padW = 1, padH = 1, kW = 1, kH = 1`
- 18.`RuntimeError: **.pt is a zip archive(did you mean to use torch.jit.load()?)`
- 19. `'pip' 不是内部或外部命令,也不是可运行的程序 或批处理文件`
- 20. `ipykernel_launcher.py: error: unrecognized arguments: -f /root/.local/share/jupyter/runtime/kernel-347b9f63-bf6e-4d91-8b6f-9a9b9b10e20a.json An exception has occurred, use %tb to see the full traceback.`
- 21. `raise TypeError("Invalid dimensions for image data") TypeError: Invalid dimensions for image data`
- 22. `RuntimeError: Expected object of scalar type Float but got scalar type Double for argument #4 'mat1'`
- 23.`RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation: [torch.cuda.FloatTensor [16, 64, 160, 160]], which is output 0 of ReluBackward1, is at version 2; expected version 1 instead. Hint: enable anomal`①
- 24.`TypeError: forward() takes 1 positional argument but 2 were given`
- 25.`ValueError: num_samples should be a positive integer value, but got num_samples=0`
- 26.`BrokenPipeError: [Errno 32] Broken pipe`
- 27.`RuntimeError: one of the variables needed for gradient computation has been modified by an ==inplace operation==: [torch.FloatTensor [10, 6]], which is output 0 of NativeBatchNormBackward, is at version 1; expected version 0 instead. Hint: enable anomaly detection to find the operation that failed to compute its gradient, with torch.autograd.set_detect_anomaly(True).`②
- 28.构造子函数/类过程中的两个SyntaxError
- 29.`FileNotFoundError: [Errno 2] No such file or directory:`
- 30.`ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()`
- 31. `FileNotFoundError: [WinError 3]` 系统找不到指定的路径。
- 32.字符串中含有双引号/单引号出差 `SyntaxError: invalid syntax`
- 33.`OSError: [Errno 22] Invalid argument: 'E:\x01.pkl'`
- 34.`RuntimeError: Trying to backward through the graph a second time, but the buffers have already been freed. Specify retain_graph=True when calling backward the first time.`
- 35.`TypeError: 'Tensor' object is not callable`
- 36.`AttributeError: 'builtin_function_or_method' object has no attribute 'fftn'`
- 37.`TypeError: __main__.conv_relu is not a Module subclass'`
- 37. pandas 读取数据进行运算时报错:`TypeError: unsupported operand type(s) for +: 'int' and 'str'`
- 38.`AttributeError: 'builtin_function_or_method' object has no attribute 'fftn'`
- 38.`ValueError: a must be 1-dimensional`
- 39.`ImportError: cannot import name 'evaluate' from 'test' (c:\python37\lib\test\__init__.py)`
- 40.`ValueError: dictionary update sequence element #0 has length 1; 2 is required`
- 41.编译过程中的错误
- 42.使用nn.DataParallel训练后加载权重出错
- 43.python/numpy读取pkl文件报错
- 44.`ValueError: Usecols do not match columns, columns expected but not found:`
- 50.环境配置
- 51. PyTorch Not Implemented Error
- 52.ValueError: invalid literal for int() with base 10: '3.1'
- 53.TypeError: write() argument must be str, not bytes
- 54.UnicodeDecodeError: 'utf-8' codec can't decode bytes in position 15-16: invalid continuation byte
- 55. IndexError: index out of range in self
- 56.RuntimeError: expected scalar type Double but found Float
- 57.raise RuntimeError("No rendezvous handler for {}: //".format(result.scheme))
- 58. java.io.IOException: ImageJ cannot open 48-bit LZW compressed TIFFs with predictor
- 59. `awk: line 1: runaway string constant "%s %s ...`
- 60.RuntimeError: tcl_asyncdelete async handler deleted by the wrong thread
- 参考文件
1.调用函数返回‘None’type
def g(x,n):
if (x%2!=0):
print(n)