請我喝杯咖啡☕
*我的貼文解釋了 CIFAR-100。
CIFAR100()可以使用CIFAR-100資料集,如下所示:
*備忘錄:
- 第一個參數是 root(必要類型:str 或 pathlib.Path)。 *絕對或相對路徑都是可能的。
- 第二個參數是 train(Optional-Default:True-Type:bool)。 *如果為 True,則使用訓練資料(50,000 張圖像),如果為 False,則使用測試資料(10,000 張圖像)。
- 第三個參數是transform(Optional-Default:None-Type:callable)。
- 第四個參數是 target_transform(Optional-Default:None-Type:callable)。
- 第五個參數是 download(可選-預設:False-類型:bool):
*備註:
- 如果為 True,則從網路下載資料集並解壓縮(解壓縮)到根目錄。
- 如果為 True 並且資料集已下載,則將其提取。
- 如果為 True 並且資料集已下載並提取,則不會發生任何事情。
- 如果資料集已經下載並提取,則應該為 False,因為它速度更快。
- 您可以從這裡手動下載並提取資料集(cifar-100-python.tar.gz)到data/cifar-100-python/。
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 datapoints: 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") </pil.image.image></pil.image.image></pil.image.image></pil.image.image></pil.image.image></bound>
以上是PyTorch 中的 CIFAR的詳細內容。更多資訊請關注PHP中文網其他相關文章!

ForhandlinglargedatasetsinPython,useNumPyarraysforbetterperformance.1)NumPyarraysarememory-efficientandfasterfornumericaloperations.2)Avoidunnecessarytypeconversions.3)Leveragevectorizationforreducedtimecomplexity.4)Managememoryusagewithefficientdata

Inpython,ListSusedynamicMemoryAllocationWithOver-Asalose,而alenumpyArraySallaySallocateFixedMemory.1)listssallocatemoremoremoremorythanneededinentientary上,respizeTized.2)numpyarsallaysallaysallocateAllocateAllocateAlcocateExactMemoryForements,OfferingPrediCtableSageButlessemageButlesseflextlessibility。

Inpython,YouCansspecthedatatAtatatPeyFelemereModeRernSpant.1)Usenpynernrump.1)Usenpynyp.dloatp.dloatp.ploatm64,formor professisconsiscontrolatatypes。

NumPyisessentialfornumericalcomputinginPythonduetoitsspeed,memoryefficiency,andcomprehensivemathematicalfunctions.1)It'sfastbecauseitperformsoperationsinC.2)NumPyarraysaremorememory-efficientthanPythonlists.3)Itoffersawiderangeofmathematicaloperation

Contiguousmemoryallocationiscrucialforarraysbecauseitallowsforefficientandfastelementaccess.1)Itenablesconstanttimeaccess,O(1),duetodirectaddresscalculation.2)Itimprovescacheefficiencybyallowingmultipleelementfetchespercacheline.3)Itsimplifiesmemorym

SlicingaPythonlistisdoneusingthesyntaxlist[start:stop:step].Here'showitworks:1)Startistheindexofthefirstelementtoinclude.2)Stopistheindexofthefirstelementtoexclude.3)Stepistheincrementbetweenelements.It'susefulforextractingportionsoflistsandcanuseneg

numpyallowsforvariousoperationsonArrays:1)basicarithmeticlikeaddition,減法,乘法和division; 2)evationAperationssuchasmatrixmultiplication; 3)element-wiseOperations wiseOperationswithOutexpliitloops; 4)

Arresinpython,尤其是Throughnumpyandpandas,weessentialFordataAnalysis,offeringSpeedAndeffied.1)NumpyArseNable efflaysenable efficefliceHandlingAtaSetSetSetSetSetSetSetSetSetSetSetsetSetSetSetSetsopplexoperationslikemovingaverages.2)


熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

DVWA
Damn Vulnerable Web App (DVWA) 是一個PHP/MySQL的Web應用程序,非常容易受到攻擊。它的主要目標是成為安全專業人員在合法環境中測試自己的技能和工具的輔助工具,幫助Web開發人員更好地理解保護網路應用程式的過程,並幫助教師/學生在課堂環境中教授/學習Web應用程式安全性。 DVWA的目標是透過簡單直接的介面練習一些最常見的Web漏洞,難度各不相同。請注意,該軟體中

Atom編輯器mac版下載
最受歡迎的的開源編輯器

VSCode Windows 64位元 下載
微軟推出的免費、功能強大的一款IDE編輯器

Dreamweaver Mac版
視覺化網頁開發工具

SublimeText3 Mac版
神級程式碼編輯軟體(SublimeText3)