解决 Python 中 'ValueError: Expected 2D array, got 1D array instead' 错误
E://论文程序//LBPGLCM_SVM_Project-main//LBP朱笔特改.py:84: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray./n data = np.array(data)/nTraceback (most recent call last):/n File /'E://论文程序//LBPGLCM_SVM_Project-main//LBP朱笔特改.py/', line 97, in array.reshape(-1, 1)来将数据数组转换为二维形式。/n/n对于data数组,你可以将其修改为以下代码来进行转换:/n/npython/ndata = np.array(data).reshape(-1, 1)/n/n/n对于labels数组,你可以使用以下代码进行转换:/n/npython/nlabels = np.array(labels).reshape(-1, 1)/n/n/n这样修改后,你将得到二维的data和labels数组,然后可以继续进行训练。
原文地址: https://www.cveoy.top/t/topic/pHsM 著作权归作者所有。请勿转载和采集!