Beli Saya Kopi☕
*Siaran saya menerangkan CIFAR-100.
CIFAR100() boleh menggunakan set data CIFAR-100 seperti yang ditunjukkan di bawah:
*Memo:
from torchvision.datasets import CIFAR100 train_data = CIFAR100( root="data" ) train_data = CIFAR100( root="data", train=True, transform=None, target_transform=None, download=False ) test_data = CIFAR100( root="data", train=False ) len(train_data), len(test_data) # (50000, 10000) train_data # Dataset CIFAR100 # Number of datapoints: 50000 # 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 CIFAR10.download of Dataset CIFAR100 # Number of datapoints: 50000 # Root location: data # Split: Train> len(train_data.classes), train_data.classes # (100, # ['apple', 'aquarium_fish', 'baby', 'bear', 'beaver', 'bed', # 'bicycle', 'bottle', 'bowl', ..., 'wolf', 'woman', 'worm'] train_data[0] # (<PIL.Image.Image image mode=RGB size=32x32>, 19) train_data[1] # (<PIL.Image.Image image mode=RGB size=32x32>, 29) train_data[2] # (<PIL.Image.Image image mode=RGB size=32x32>, 0) train_data[3] # (<PIL.Image.Image image mode=RGB size=32x32>, 11) train_data[4] # (<PIL.Image.Image image mode=RGB size=32x32>, 1) import matplotlib.pyplot as plt def show_images(data, main_title=None): plt.figure(figsize=(10, 5)) plt.suptitle(t=main_title, y=1.0, fontsize=14) for i, (im, lab) in enumerate(data, start=1): plt.subplot(2, 5, i) plt.title(label=lab) plt.imshow(X=im) if i == 10: break plt.tight_layout() plt.show() show_images(data=train_data, main_title="train_data") show_images(data=test_data, main_title="test_data")
Atas ialah kandungan terperinci CIFAR dalam PyTorch. Untuk maklumat lanjut, sila ikut artikel berkaitan lain di laman web China PHP!