女人自慰AV免费观看内涵网,日韩国产剧情在线观看网址,神马电影网特片网,最新一级电影欧美,在线观看亚洲欧美日韩,黄色视频在线播放免费观看,ABO涨奶期羡澄,第一导航fulione,美女主播操b

電子發(fā)燒友App

硬聲App

0
  • 聊天消息
  • 系統(tǒng)消息
  • 評(píng)論與回復(fù)
登錄后你可以
  • 下載海量資料
  • 學(xué)習(xí)在線課程
  • 觀看技術(shù)視頻
  • 寫(xiě)文章/發(fā)帖/加入社區(qū)
會(huì)員中心
創(chuàng)作中心

完善資料讓更多小伙伴認(rèn)識(shí)你,還能領(lǐng)取20積分哦,立即完善>

3天內(nèi)不再提示
創(chuàng)作
電子發(fā)燒友網(wǎng)>電子資料下載>電子資料>PyTorch教程22.9之樸素貝葉斯

PyTorch教程22.9之樸素貝葉斯

2023-06-06 | pdf | 0.22 MB | 次下載 | 免費(fèi)

資料介紹

在前面幾節(jié)中,我們了解了概率論和隨機(jī)變量。為了將這一理論付諸實(shí)踐,讓我們介紹一下樸素貝葉斯分類器。這只使用概率基礎(chǔ)知識(shí)來(lái)讓我們執(zhí)行數(shù)字分類。

學(xué)習(xí)就是做假設(shè)。如果我們想要對(duì)以前從未見(jiàn)過(guò)的新數(shù)據(jù)示例進(jìn)行分類,我們必須對(duì)哪些數(shù)據(jù)示例彼此相似做出一些假設(shè)。樸素貝葉斯分類器是一種流行且非常清晰的算法,它假設(shè)所有特征彼此獨(dú)立以簡(jiǎn)化計(jì)算。在本節(jié)中,我們將應(yīng)用此模型來(lái)識(shí)別圖像中的字符。

%matplotlib inline
import math
import torch
import torchvision
from d2l import torch as d2l

d2l.use_svg_display()
%matplotlib inline
import math
from mxnet import gluon, np, npx
from d2l import mxnet as d2l

npx.set_np()
d2l.use_svg_display()
%matplotlib inline
import math
import tensorflow as tf
from d2l import tensorflow as d2l

d2l.use_svg_display()

22.9.1。光學(xué)字符識(shí)別

MNIST ( LeCun et al. , 1998 )是廣泛使用的數(shù)據(jù)集之一。它包含 60,000 張用于訓(xùn)練的圖像和 10,000 張用于驗(yàn)證的圖像。每個(gè)圖像包含一個(gè)從 0 到 9 的手寫(xiě)數(shù)字。任務(wù)是將每個(gè)圖像分類為相應(yīng)的數(shù)字。

GluonMNIST在模塊中提供了一個(gè)類data.vision來(lái)自動(dòng)從 Internet 檢索數(shù)據(jù)集。隨后,Gluon 將使用已經(jīng)下載的本地副本。train我們通過(guò)將參數(shù)的值分別設(shè)置為True來(lái)指定我們是請(qǐng)求訓(xùn)練集還是測(cè)試集False每個(gè)圖像都是一個(gè)灰度圖像,寬度和高度都是28具有形狀(28,28,1). 我們使用自定義轉(zhuǎn)換來(lái)刪除最后一個(gè)通道維度。此外,數(shù)據(jù)集用無(wú)符號(hào)表示每個(gè)像素8位整數(shù)。我們將它們量化為二進(jìn)制特征以簡(jiǎn)化問(wèn)題。

data_transform = torchvision.transforms.Compose([
  torchvision.transforms.ToTensor(),
  lambda x: torch.floor(x * 255 / 128).squeeze(dim=0)
])

mnist_train = torchvision.datasets.MNIST(
  root='./temp', train=True, transform=data_transform, download=True)
mnist_test = torchvision.datasets.MNIST(
  root='./temp', train=False, transform=data_transform, download=True)
Downloading http://yann.lecun.com/exdb/mnist/train-images-idx3-ubyte.gz
Downloading http://yann.lecun.com/exdb/mnist/train-images-idx3-ubyte.gz to ./temp/MNIST/raw/train-images-idx3-ubyte.gz
 0%|     | 0/9912422 [00:00
Extracting ./temp/MNIST/raw/train-images-idx3-ubyte.gz to ./temp/MNIST/raw

Downloading http://yann.lecun.com/exdb/mnist/train-labels-idx1-ubyte.gz
Downloading http://yann.lecun.com/exdb/mnist/train-labels-idx1-ubyte.gz to ./temp/MNIST/raw/train-labels-idx1-ubyte.gz
 0%|     | 0/28881 [00:00
Extracting ./temp/MNIST/raw/train-labels-idx1-ubyte.gz to ./temp/MNIST/raw

Downloading http://yann.lecun.com/exdb/mnist/t10k-images-idx3-ubyte.gz
Downloading http://yann.lecun.com/exdb/mnist/t10k-images-idx3-ubyte.gz to ./temp/MNIST/raw/t10k-images-idx3-ubyte.gz
 0%|     | 0/1648877 [00:00
Extracting ./temp/MNIST/raw/t10k-images-idx3-ubyte.gz to ./temp/MNIST/raw

Downloading http://yann.lecun.com/exdb/mnist/t10k-labels-idx1-ubyte.gz
Downloading http://yann.lecun.com/exdb/mnist/t10k-labels-idx1-ubyte.gz to ./temp/MNIST/raw/t10k-labels-idx1-ubyte.gz
 0%|     | 0/4542 [00:00
Extracting ./temp/MNIST/raw/t10k-labels-idx1-ubyte.gz to ./temp/MNIST/raw
def transform(data, label):
  return np.floor(data.astype('float32') / 128).squeeze(axis=-1), label

mnist_train = gluon.data.vision.MNIST(train=True, transform=transform)
mnist_test = gluon.data.vision.MNIST(train=False, transform=transform)
((train_images, train_labels), (
  test_images, test_labels)) = tf.keras.datasets.mnist.load_data()

# Original pixel values of MNIST range from 0-255 (as the digits are stored as
# uint8). For this section, pixel values that are greater than 128 (in the
# original image) are converted to 1 and values that are less than 128 are
# converted to 0. See section 18.9.2 and 18.9.3 for why
train_images = tf.floor(tf.constant(train_images / 128, dtype = tf.float32))
test_images = tf.floor(tf.constant(test_images / 128, dtype = tf.float32))

train_labels = tf.constant(train_labels, dtype = tf.int32)
test_labels = tf.constant(test_labels, dtype = tf.int32)

我們可以訪問(wèn)一個(gè)特定的示例,其中包含圖像和相應(yīng)的標(biāo)簽

image, label = mnist_train[2]
image.shape, label
(torch.Size([28, 28]), 4)
image, label = mnist_train[2]
image.shape, label
((28, 28), array(4, dtype=int32))
image, label = train_images[2], train_labels[2]
image.shape, label.numpy()
(TensorShape([28, 28]), 4)

我們的示例存儲(chǔ)在此處的變量中image,對(duì)應(yīng)于高度和寬度為28像素。

image.shape, image.dtype
(torch.Size([28, 28]), torch.float32)
image.shape, image.dtype
((28, 28), dtype('float32'))
image.shape, image.dtype
(TensorShape([28, 28]), tf.float32)

我們的代碼將每個(gè)圖像的標(biāo)簽存儲(chǔ)為標(biāo)量。它的類型是 32位整數(shù)。

label, 
下載該資料的人也在下載 下載該資料的人還在閱讀
更多 >

評(píng)論

查看更多

下載排行

本周

  1. 1山景DSP芯片AP8248A2數(shù)據(jù)手冊(cè)
  2. 1.06 MB  |  532次下載  |  免費(fèi)
  3. 2RK3399完整板原理圖(支持平板,盒子VR)
  4. 3.28 MB  |  339次下載  |  免費(fèi)
  5. 3TC358743XBG評(píng)估板參考手冊(cè)
  6. 1.36 MB  |  330次下載  |  免費(fèi)
  7. 4DFM軟件使用教程
  8. 0.84 MB  |  295次下載  |  免費(fèi)
  9. 5元宇宙深度解析—未來(lái)的未來(lái)-風(fēng)口還是泡沫
  10. 6.40 MB  |  227次下載  |  免費(fèi)
  11. 6迪文DGUS開(kāi)發(fā)指南
  12. 31.67 MB  |  194次下載  |  免費(fèi)
  13. 7元宇宙底層硬件系列報(bào)告
  14. 13.42 MB  |  182次下載  |  免費(fèi)
  15. 8FP5207XR-G1中文應(yīng)用手冊(cè)
  16. 1.09 MB  |  178次下載  |  免費(fèi)

本月

  1. 1OrCAD10.5下載OrCAD10.5中文版軟件
  2. 0.00 MB  |  234315次下載  |  免費(fèi)
  3. 2555集成電路應(yīng)用800例(新編版)
  4. 0.00 MB  |  33566次下載  |  免費(fèi)
  5. 3接口電路圖大全
  6. 未知  |  30323次下載  |  免費(fèi)
  7. 4開(kāi)關(guān)電源設(shè)計(jì)實(shí)例指南
  8. 未知  |  21549次下載  |  免費(fèi)
  9. 5電氣工程師手冊(cè)免費(fèi)下載(新編第二版pdf電子書(shū))
  10. 0.00 MB  |  15349次下載  |  免費(fèi)
  11. 6數(shù)字電路基礎(chǔ)pdf(下載)
  12. 未知  |  13750次下載  |  免費(fèi)
  13. 7電子制作實(shí)例集錦 下載
  14. 未知  |  8113次下載  |  免費(fèi)
  15. 8《LED驅(qū)動(dòng)電路設(shè)計(jì)》 溫德?tīng)栔?/a>
  16. 0.00 MB  |  6656次下載  |  免費(fèi)

總榜

  1. 1matlab軟件下載入口
  2. 未知  |  935054次下載  |  免費(fèi)
  3. 2protel99se軟件下載(可英文版轉(zhuǎn)中文版)
  4. 78.1 MB  |  537798次下載  |  免費(fèi)
  5. 3MATLAB 7.1 下載 (含軟件介紹)
  6. 未知  |  420027次下載  |  免費(fèi)
  7. 4OrCAD10.5下載OrCAD10.5中文版軟件
  8. 0.00 MB  |  234315次下載  |  免費(fèi)
  9. 5Altium DXP2002下載入口
  10. 未知  |  233046次下載  |  免費(fèi)
  11. 6電路仿真軟件multisim 10.0免費(fèi)下載
  12. 340992  |  191187次下載  |  免費(fèi)
  13. 7十天學(xué)會(huì)AVR單片機(jī)與C語(yǔ)言視頻教程 下載
  14. 158M  |  183279次下載  |  免費(fèi)
  15. 8proe5.0野火版下載(中文版免費(fèi)下載)
  16. 未知  |  138040次下載  |  免費(fèi)