python、深度学习等代码错误集合

1、RuntimeError: cuda runtime error (710) : device-side assert triggered at C:/w/1/s/tmp_conda_3.7_104508/conda/conda-bld/pytorch_1572950778684/work/aten/src\THC/generic/THCTensorMath.cu:26

解决办法:检查一下自己的类别,是否与输出类别不一致
我是因为我是二分类任务,但是我的神经单元最后一层输出的一个神经单元就出现了这个错误。

2、TypeError: Cannot cast ufunc add output from dtype(‘float64’) to dtype(‘int32’) with casting rule ‘same_kind’

解决办法:使用python 列表或者元组创建,array的dtype将会取决于您输入元素的类型。如果您输入的数字都为int或者都为float,那么array的类型也将是这个。
将生成的数组

A = np.array([[0,1,1,0,0],[1,0,0,1,0],[1,0,0,1,1],[0,1,1,0,1],[0,0,1,1,0]])

改成

A = np.array([[0.0,1.0,1.0,0.0,0.0],[1.0,0.0,0.0,1.0,0.0],[1.0,0.0,0.0,1.0,1.0],[0.0,1.0,1.0,0.0,1.0],[0.0,0.0,1.0,1.0,0.0]])

即可

猜你喜欢

转载自blog.csdn.net/weixin_43183872/article/details/111451217