python-matplotlib IndexError:列表索引超出范围[关闭]
发布时间:2022-05-10 16:57:12 257
相关标签: # node.js
我无法理解我写错了什么。我尝试将值从 1 更改为 0 或 2,但没有帮助。my_dataset 用于存储数据和目标值
my_dataset = []
for image_file in glob.glob('my_image/_my_?.png'):
label_y = int(image_file[-5:-4])
image_list = scipy.misc.imread(image_file, flatten=True)
image_data = 255.0 - image_list.reshape(784)
my_data = np.append(label_y, image_data)
my_dataset.append(my_data)
room_choices = 0
matplotlib.pyplot.imshow(my_dataset[room_choices][1:].reshape(28,28))
IndexError Traceback (most recent call last)
/var/folders/7x/q0gw9knx0klf7ngkgvd95wj40000gn/T/ipykernel_62654/3212784161.py in <module>
1 room_choices = 0
----> 2 matplotlib.pyplot.imshow(my_dataset[room_choices][1:].reshape(28,28), cmap='Greys', interpolation='None')
3 correct_label = my_dataset[room_choices][0]
4
5 input_x = my_dataset[room_choices][1:]
IndexError: list index out of range
期望的答案:
[[ 6.66671197e-01]
[ 2.56659427e-03]
[ 9.32429328e-03]
[ 6.77700446e-05]
[ 1.92683835e-03]
[ 2.02324562e-03]
[ 3.13702331e-03]
[ 8.52300221e-03]
[ 2.36677373e-04]
[ 4.81128855e-03]]
Min value: 6.77700445779e-05
Max value: 0.666671197018
guessed wrong!: 0
guessed right!!!
特别声明:以上内容(图片及文字)均为互联网收集或者用户上传发布,本站仅提供信息存储服务!如有侵权或有涉及法律问题请联系我们。
举报