sklearn.neural_network.BernoulliRB?

class sklearn.neural_network.BernoulliRBM(n_components=256, *, learning_rate=0.1, batch_size=10, n_iter=10, verbose=0, random_state=None)

[源碼]

伯努利限制玻爾茲曼機(RBM)。

具有二值化可見單位和二值化隱藏單位的限制玻爾茲曼機。參數估計使用隨機最大似然(SML),也稱為持久對比散度(PCD)[2]。

這個實現的時間復雜度為O(d ** 2)假定d?n_features?n_components。

用戶指南中閱讀更多內容。

參數 說明
n_components int, default=256
二值化隱藏單位數
learning_rate float, default=0.1
用于權重更新的學習率。強烈建議調優這個超參數。合理值在10 ** [0.,-3.]范圍內。
batch_size int, default=10
每個小批量的樣本數量。
n_iter int, default=10
訓練數據集在訓練期間要執行的迭代或掃描次數。
verbose int, default=0
詳細程度。默認為零,表示靜默模式。
random_state integer or RandomState, default=None
確定以下各項的隨機數生成:

- 從可見層和隱藏層進行吉布斯(Gibbs)采樣。
- 初始化組件,在擬合過程中從層中采樣。
- 在對樣本評分時破壞數據。

在多個函數調用之間傳遞一個整數以獲得可重復的結果。請參閱詞匯表
屬性 說明
intercept_hidden_ array-like, shape (n_components,)
隱藏單位的偏差。
intercept_visible_ array-like, shape (n_features,)
可見單位的偏差。
components_ array-like, shape (n_components, n_features)
權重矩陣,可見單元數中的n_features和n_components是隱藏單元數。
h_samples_ array-like, shape (batch_size, n_components)
隱藏激活是從模型分布中采樣的,其中,每個小批量的示例數中的batch_size和n_components是隱藏單元數。

參考文獻

[1] Hinton, G. E., Osindero, S. and Teh, Y. A fast learning algorithm for

deep belief nets. Neural Computation 18, pp 1527-1554. https://www.cs.toronto.edu/~hinton/absps/fastnc.pdf

[2] Tieleman, T. Training Restricted Boltzmann Machines using

Approximations to the Likelihood Gradient. International Conference on Machine Learning (ICML) 2008

示例

>>> import numpy as np
>>> from sklearn.neural_network import BernoulliRBM
>>> X = np.array([[000], [011], [101], [111]])
>>> model = BernoulliRBM(n_components=2)
>>> model.fit(X)
BernoulliRBM(n_components=2)

方法

方法 說明
fit(X[, y]) 將模型擬合到數據X。
fit_transform(X[, y]) 擬合數據,然后對其進行轉換。
get_params([deep]) 獲取這個估計器的參數
gibbs(v) 執行一個吉布斯采樣步驟。
partial_fit(X[, y]) 將模型擬合到數據X,其中應包含數據的一部分。
score_samples(X) 計算X的偽似然。
set_params(**params) 為這個估計器設置參數
transform(X) 計算隱藏層激活概率P(h = 1/v=X)
__init__(n_components=256, *, learning_rate=0.1, batch_size=10, n_iter=10, verbose=0, random_state=None)

[源碼]

初始化self。詳情可參閱 type(self)的幫助。

fit(X, y=None)

[源碼]

將模型擬合到數據X。

參數 說明
X {array-like, sparse matrix} of shape (n_samples, n_features)
用于訓練的數據。
返回值 說明
self BernoulliRBM
擬合的模型。
fit_transform(X, y=None, **fit_params)

[源碼]

擬合數據,然后對其進行轉換。

使用可選參數fit_params將擬合轉換到X和y,并返回X的轉換版本。

參數 說明
X {array-like, sparse matrix, dataframe} of shape (n_samples, n_features)
y ndarray of shape (n_samples,), default=None
目標值
**fit_params dict
其他擬合參數。
返回值 說明
X_new ndarray array of shape (n_samples, n_features_new)
轉換后的數組。
get_params(deep=True)

[源碼]

獲取這個估計器的參數

參數 說明
deep bool, default=True
如果為True,則將返回這個估計器的參數和所包含的估計器子對象。
返回值 說明
params mapping of string to any
參數名映射到其值。
gibbs(v)

[源碼]

執行一個吉布斯采樣步驟。

參數 說明
v ndarray of shape (n_samples, n_features)
可見層的起始值
返回值 說明
v_new ndarray of shape (n_samples, n_features)
一個吉布斯步驟后,可見層的值。
partial_fit(X, y=None)

[源碼]

將模型擬合到數據X,其中應包含數據的一部分。

參數 說明
X ndarray of shape (n_samples, n_features)
用于訓練的數據
返回值 說明
self BernoulliRBM
擬合的模型
score_samples(X)

[源碼]

計算X的偽似然。

參數 說明
X {array-like, sparse matrix} of shape (n_samples, n_features)
可見層的值。必須為全布爾值(不檢查)。
返回值 說明
pseudo_likelihood ndarray of shape (n_samples,)
偽似然的值(似然的代理)。

這種方法是不確定的:它計算一個稱為X上的自由能的量,然后計算一個隨機損壞的X版本,并返回差的logistic函數的對數。

set_params(**params)

[源碼]

為這個估計器設置參數

參數 說明
**params dict
估計器參數
返回值 說明
self object
估計器實例
transform(X)

[源碼]

計算隱藏層激活概率P(h = 1 | v = X)。

參數 說明
X {array-like, sparse matrix} of shape (n_samples, n_features)
要轉換的數據。
返回值 說明
h ndarray of shape (n_samples, n_components)
數據的潛在表示。

sklearn.neural_network.BernoulliRBM使用示例?