我正在编写一个脚本来绘制与图像集相对应的标签中的前5个项目。服装套装对每个团队的名称进行分类。我画了但是,我没有将输出分类。第一行输出应仅是T恤/上衣的前5项,第二行应是裤子等的前5项。
import numpy as np
import matplotlib.pyplot as plt
fashion_image = 'fashion_train-images.idx3-ubyte'
fashion_label = 'fashion_train-labels.idx1-ubyte'
##### Load the data #### ## This returns image and labels for the fashion dataset
f_img = loadMNISTImages(fashion_image)
f_label = loadMNISTLabels(fashion_label)
# Mapping Classes
clothing = {0 : 'T-shirt/top',
1 : 'Trouser',
2 : 'Pullover',
3 : 'Dress',
4 : 'Coat',
5 : 'Sandal',
6 : 'Shirt',
7 : 'Sneaker',
8 : 'Bag',
9 : 'Ankle boot'}
###### PLOT ###########
classes1 = np.arange(5)
for clasval in classes1:
index = [i for i in range(len(f_img)) if f_label[i]==clasval][:5] ### Take the first 5 images
fig, ax = plt.subplots(1,5, figsize = (10,5))
for i in range(5):
ax[i].imshow(f_img[index[i]].reshape([28,28]))
ax[i].set_title('Label%d '%index[i])
ax[i].xaxis.grid(True)
ax[i].yaxis.grid(True)
plt.show()