错题本

报错信息:Cannot cast ufunc subtract output from dtype('float64') to dtype('int64') with casting rule 'same_kind'

输入的数据类型为浮点型,需要的数据类型是整形。

可以通过下面的语句完成类型转换

np.array(dta,dtype=np.float) 

 

AttributeError: '_io.TextIOWrapper' object has no attribute 'xreadlines'

  python 2 中有file.xreadlines(),作为一个迭代器,一次读取一行文件,在python3中已经移除,可使用file.readlines()代替

 

matrix 和 np.array 的逆

np.linalg.inv

matrix.I

Open CV  imwrite

 cv.imwrite('filename', img)

OpenCv error: (-2) could not find a writer for the specified extension in function cv::imwrite_

filename 缺少拓展名

cv2.error: OpenCV(4.1.0) /io/opencv/modules/imgproc/src/resize.cpp:3718: error: (-215:Assertion failed) !ssize.empty() in function 'resize'

>>>  img0 = cv2.imread('dir')
>>> img1 = img0[x0:x1, y0:y1, :]
>>> img2 = cv2.resize(img1, (128, 128))

cv2.error: OpenCV(4.1.0) /io/opencv/modules/imgproc/src/resize.cpp:3718: error: (-215:Assertion failed) !ssize.empty() in function 'resize'
这是由于img1的w,h为0导致的
注意处理img1时要满足
(x0>x1)&(y0>y1)
否则会导致img.shape[:2]=(0,0)

 

can't assign to operator

变量名出错

a-b = np.load('a-b.npy')
改为
a_b = np.load('a-b.npy')

+ - / 之类operator不能用于变量名中
出现改错误应当检查变量名

  

AttributeError: 'ProgbarLogger' object has no attribute 'log_values'

generator 中没有传入样本

  

 

posted @ 2019-06-12 10:13  Pent°  阅读(1118)  评论(0编辑  收藏  举报