◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。
请我喝杯咖啡☕
*我的帖子解释了 kmnist。
kmnist() 可以使用 kmnist 数据集,如下所示:
*备忘录:
from torchvision.datasets import kmnist train_data = kmnist( root="data" ) train_data = kmnist( root="data", train=true, transform=none, target_transform=none, download=false ) test_data = kmnist( root="data", train=false ) len(train_data), len(test_data) # (60000, 10000) train_data # dataset kmnist # number of datapoints: 60000 # root location: data # split: train train_data.root # 'data' train_data.train # true print(train_data.transform) # none print(train_data.target_transform) # none train_data.download # <bound method mnist.download of dataset kmnist # number of datapoints: 60000 # root location: data # split: train> train_data[0] # (<pil.image.image image mode=l size=28x28>, 8) train_data[1] # (<pil.image.image image mode=l size=28x28>, 7) train_data[2] # (<pil.image.image image mode=l size=28x28>, 0) train_data[3] # (<pil.image.image image mode=l size=28x28>, 1) train_data[4] # (<pil.image.image image mode=l size=28x28>, 4) train_data.classes # ['o', 'ki', 'su', 'tsu', 'na', 'ha', 'ma', 'ya', 're', 'wo']
from torchvision.datasets import KMNIST train_data = KMNIST( root="data", train=True ) test_data = KMNIST( root="data", train=False ) import matplotlib.pyplot as plt def show_images(data): plt.figure(figsize=(12, 2)) col = 5 for i, (image, label) in enumerate(data, 1): plt.subplot(1, col, i) plt.title(label) plt.imshow(image) if i == col: break plt.show() show_images(data=train_data) show_images(data=test_data)
◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。