请我喝杯咖啡☕
*我的帖子解释了 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)
以上是PyTorch 中的 KMNIST的详细内容。更多信息请关注PHP中文网其他相关文章!