【发布时间】:2020-08-08 02:53:29
【问题描述】:
我正在关注 YouTube (https://www.youtube.com/watch?v=y1ZrOs9s2QA&feature=youtu.be) 上的教程,代码可以在这里找到:https://github.com/murtazahassan/Digits-Classification/blob/master/OCR_CNN_Trainning.py
但是当我尝试运行下面的代码时,我得到了错误:TypeError: only integer scalar arrays can be convert to a scalar index.
x_train = np.array(list(map(preprocess, x_train)))
x_test = np.array(list(map(preprocess, x_test)))
x_validation = np.array(list(map(preprocess, x_validation)))
x_train = x_train.reshape(x_train[0], x_train[1], x_train[2], 1)
x_test = x_test.reshape(x_test[0], x_test[1], x_test[2], 1)
x_validation = x_validation.reshape(x_validation[0], x_validation[1], x_validation[2], 1)
我找到了这个 (TypeError: only integer scalar arrays can be converted to a scalar index , while trying kfold cv) 和这个 (TypeError when indexing a list with a NumPy array: only integer scalar arrays can be converted to a scalar index),但它对我没有帮助。我做错了什么?
【问题讨论】:
-
使用 numpy,如果你对所有数组都执行
name.dtype,你会得到什么? -
@duckboycool 我得到 float64