日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) >

Deep learning前的图像预处理

發(fā)布時(shí)間:2025/10/17 23 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Deep learning前的图像预处理 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

(1)調(diào)節(jié)尺寸

As data(Images) few into the NN should be scaled according the image size that the NN is designed to take, usually a square i.e 100x100,250x250


(2) 特征標(biāo)準(zhǔn)化(Feature Standardization)

  • 【參考文獻(xiàn)】
    • https://blog.csdn.net/xjp_xujiping/article/details/102981133
    • https://blog.csdn.net/kane7csdn/article/details/86475918
    • https://blog.csdn.net/dengheng4891/article/details/101446368

特征標(biāo)準(zhǔn)化(Feature Standardization)
特征標(biāo)準(zhǔn)化的目的是使數(shù)據(jù)集中所有特征都具有零均值和單位方差,即數(shù)據(jù)的每一個(gè)維度具有零均值和單位方差,這也是比較常見(jiàn)的一種歸一化方法,比如使用SVM時(shí)候也要進(jìn)行類(lèi)似處理。在實(shí)際應(yīng)用中,特征標(biāo)準(zhǔn)化的具體做法是:首先計(jì)算每一個(gè)維度上數(shù)據(jù)的均值(使用全體數(shù)據(jù)計(jì)算),之后在每一個(gè)維度上都減去該均值。下一步便是在數(shù)據(jù)的每一維度上除以該維度上數(shù)據(jù)的標(biāo)準(zhǔn)差。

例如(X)是一個(gè)訓(xùn)練樣本集,包含m個(gè)訓(xùn)練樣本且每個(gè)訓(xùn)練樣本的維數(shù)是n。應(yīng)用特征標(biāo)準(zhǔn)化時(shí)先計(jì)算各行數(shù)據(jù)的均值,然后樣本集(X)減去該均值得到零均值化后的樣本集(X{’})。之后(X{’})的各行除以該行數(shù)據(jù)的標(biāo)準(zhǔn)差就會(huì)得到特征標(biāo)準(zhǔn)化后的樣本。

若輸入是自然彩色圖像,由于色彩通道間并不存在平穩(wěn)特性,因此通常對(duì)數(shù)據(jù)進(jìn)行特征縮放(使像素值位于 [0,1] 區(qū)間)。然后再進(jìn)行PCA/ZCA白化等操作,在白化前需進(jìn)行特征分量均值歸零(即使特征的每一個(gè)維度具有零均值,通常不需要除以各維度數(shù)據(jù)的標(biāo)準(zhǔn)差,因?yàn)楦骶S度標(biāo)準(zhǔn)差很接近)。在UFLDL教程的練習(xí)中(linear decoder)采用的是這種方法,而在有些論文中,也會(huì)采用第二種方法(逐樣本去均值和除以標(biāo)準(zhǔn)差),如論文“An Analysis of Single-Layer Networks in Unsupervised Feature Learning”,這樣在后續(xù)白化處理時(shí)是不是還需要再對(duì)各維度進(jìn)行零均值化(因?yàn)橛?jì)算協(xié)方差矩陣時(shí)需要這一步)。

Here is a explanation of it from Stanford CS231n 2016 Lectures[https://cs231n.github.io/neural-networks-2/].

Normalization refers to normalizing the data dimensions so that they are of approximately the same scale. For Image data There are two common ways of achieving this normalization.

(一) 減均值Mean subtraction

One is to divide each dimension by its standard deviation, once it has been zero-centered:
(X /= np.std(X, axis = 0)).
先計(jì)算訓(xùn)練集均值,后用訓(xùn)練和測(cè)試數(shù)據(jù)再減去均值

  • 【參考文獻(xiàn)】:
    • https://blog.csdn.net/Miss_yuki/article/details/80662017
    • https://niuyuanyuanna.github.io/2018/11/08/deep_learning/data-normalization/#%E9%80%90%E6%A0%B7%E6%9C%AC%E5%9D%87%E5%80%BC%E6%B6%88%E5%87%8Fper-example-mean-subtraction

(二)Normalization, 特征縮放至[-1,1]

Another form of this preprocessing normalizes each dimension so that the min and max along the dimension is -1 and 1 respectively. It only makes sense to apply this preprocessing if you have a reason to believe that different input features have different scales (or units), but they should be of approximately equal importance to the learning algorithm. In case of images, the relative scales of pixels are already approximately equal (and in range from 0 to 255), so it is not strictly necessary to perform this additional preprocessing step.


(3)降維PCA和白化:

Dimensionality reduction RGB to Grayscale image, neural network performance is allowed to be invariant to that dimension, or to make the training problem more tractable


總結(jié)

以上是生活随笔為你收集整理的Deep learning前的图像预处理的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。