我有一个包含数据的文本文件:
0,13,10,10,11,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,14,13,12,12,12,12,12,12,12,12,12,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,11,10,10,11,11,11,10,11,11,11,11,11,11,11,11,11,11,12,12,12,12,12,12,13,13,14,14,0,0,0,0,0,0,0,0,0,0
我需要把它放入一个数组中,这样我就可以使用我的神经网络来预测输出。然而,当我使用代码时:
predict_data = input("Enter the file name of the test scan: ")
inputdata = loadtxt(predict_data, delimiter=',')
np.arange(151).reshape(1,151)
z = inputdata[:,150]
model.predict(z, batch_size=None, verbose=0, steps=None, callbacks=None, max_queue_size=10, workers=1, use_multiprocessing=False)
我得到错误:
z = inputdata[:,150]
IndexError: too many indices for array
很抱歉,如果这很乱,我是这个网站的新手。
您的输入数组是一维的,但当您这样做时:
z = inputdata[:,150]
您将其视为一个2d数组(您正试图提取input_data
的第151列(。