CodingChaozhang/Deep-Learning

为什么

Closed this issue · 1 comments

DATA_LIST.append((data_row.ocr, to_categorical(data_row.label, 10)))#为什么这一句会报错,

一个是AttributeError: 'Pandas' object has no attribute 'ocr'
另一个是如果改成DATA_LIST.append((row, np_utils.to_categorical(row.labels, 6)))
也会报这个错误module 'keras.utils' has no attribute 'to_categorical’
from keras.utils import to_categorical

DATA_LIST = []

for data_row in train_df.iloc[:].itertuples():
DATA_LIST.append((data_row.ocr, to_categorical(data_row.label, 10)))#为什么这一句会报错,
DATA_LIST = np.array(DATA_LIST)

DATA_LIST_TEST = []
for data_row in test_df.iloc[:].itertuples():
DATA_LIST_TEST.append((data_row.ocr, to_categorical(0, 10)))
DATA_LIST_TEST = np.array(DATA_LIST_TEST)

已经解决了。