我试图读取csv文件并列出其元素,但是导致错误。 该代码的目的是学习和测试用于图像分类的神经网络。我尝试读取该文件,其结果是第一行,数据的第二行都与图像有关
test_data_file = open("C:\\Users\\user\\Desktop\\Neural_Networks\\mnist_test.csv", 'r')
test_data_list = test_data_file.readlines(test_data_file)
test_data_file.close()
socrecard = []
for record in test_data_list:
all_values = record.split(',')
correct_label = int(all_values[0])
inputs = (numpy.asfarry(all_values[1:]) / 255.0 *0.99) + 0.01
outpus = n.query(inputs)
label = numpy.argmax(outpus)
if (label == correct_label):
scorecard.append(1)
else:
scorecard.append(0)
pass
pass
scorecard_array = numpy.asarray(socrecard)
print ("performace= ", socrecard_array.sum()/scorecard_array.size)
`enter code here`Traceback (most recent call last):
文件“”,第1行,在 运行文件('C:/Users/user/Desktop/Neural_Networks/test.py',wdir ='C:/ Users / user / Desktop / Neural_Networks')
runfile中的文件“ C:\ Users \ user \ Anaconda3 \ lib \ site-packages \ spyder_kernels \ customize \ spydercustomize.py”,行786 execfile(文件名,命名空间)
exec文件中的第110行,文件“ C:\ Users \ user \ Anaconda3 \ lib \ site-packages \ spyder_kernels \ customize \ spydercustomize.py” exec(compile(f.read(),文件名,'exec'),命名空间)
文件“ C:/Users/user/Desktop/Neural_Networks/test.py”,第69行,在 training_data_list = training_data_file.readlines(training_data_file)
TypeError:参数应为整数或无,而不是'_io.TextIOWrapper'